Class ConsumptionCalculator

java.lang.Object
org.kigalisim.engine.support.ConsumptionCalculator

public class ConsumptionCalculator extends Object
Calculator class for consumption stream calculations.

This class encapsulates the logic for calculating consumption streams, including unit conversion, range validation, and saving results to the engine. It provides a cleaner interface compared to the previous BiConsumer approach.

  • Constructor Details

    • ConsumptionCalculator

      public ConsumptionCalculator()
      Constructs a new ConsumptionCalculator.
  • Method Details

    • setConsumptionRaw

      public void setConsumptionRaw(EngineNumber consumptionRaw)
      Set the raw consumption value to be processed.
      Parameters:
      consumptionRaw - The raw consumption value
    • setStreamName

      public void setStreamName(String streamName)
      Set the stream name for the calculation.
      Parameters:
      streamName - The name of the stream ("consumption")
    • execute

      public void execute(Engine engine)
      Execute the consumption calculation and save the result to the engine.

      This method handles the complete calculation process including setting up the state, performing unit conversion, ensuring values are in valid ranges, and saving the result to the engine.

      Parameters:
      engine - The engine instance to use for calculation context and to save the result to
      Throws:
      IllegalStateException - if required properties are not set