Package org.kigalisim.engine.support
Class ConsumptionCalculator
java.lang.Object
org.kigalisim.engine.support.ConsumptionCalculator
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidExecute the consumption calculation and save the result to the engine.voidsetConsumptionRaw(EngineNumber consumptionRaw) Set the raw consumption value to be processed.voidsetStreamName(String streamName) Set the stream name for the calculation.
-
Constructor Details
-
ConsumptionCalculator
public ConsumptionCalculator()Constructs a new ConsumptionCalculator.
-
-
Method Details
-
setConsumptionRaw
Set the raw consumption value to be processed.- Parameters:
consumptionRaw- The raw consumption value
-
setStreamName
Set the stream name for the calculation.- Parameters:
streamName- The name of the stream ("consumption")
-
execute
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
-