Class EngineSupportUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe stream used for recycled material recovery operations.Set of valid stream names in the simulation engine. -
Method Summary
Modifier and TypeMethodDescriptionstatic UnitConvertercreateUnitConverterWithTotal(Engine engine, String stream) Creates a unit converter with total values initialized (convenience method).static UnitConvertercreateUnitConverterWithTotal(ConverterStateGetter stateGetter, String stream, EngineNumber currentValue, EngineNumber initialCharge) Creates a unit converter with total values initialized.static BigDecimalensurePositive(BigDecimal value) Ensures a value is positive, clamping to zero if negative.static BigDecimalgetDistributedRecharge(String streamName, EngineNumber totalRecharge, UseKey useKey, SimulationState simulationState) Gets the distributed recharge amount for a specific stream.static booleangetIsInRange(Optional<YearMatcher> yearMatcher, int currentYear) Check if a year matcher is in range for the given current year.static booleangetIsInRange(YearMatcher yearMatcher, int currentYear) Check if a year matcher is in range for the given current year.static booleangetIsSalesStream(String stream, boolean includeExports) Check if a stream is a sales-related stream.static booleanhasUnitBasedSalesSpecifications(SimulationState simulationState, UseKey scope) Check if sales streams were specified in equipment units for the given scope.static booleanisSalesSubstream(String name) Check if a stream name represents a sales substream (domestic or import).
-
Field Details
-
STREAM_NAMES
Set of valid stream names in the simulation engine. Includes equipment streams, sales streams, and trade streams. -
RECYCLE_RECOVER_STREAM
The stream used for recycled material recovery operations.- See Also:
-
-
Method Details
-
getIsInRange
Check if a year matcher is in range for the given current year.- Parameters:
yearMatcher- The year matcher to check (can be null)currentYear- The current year to check against- Returns:
- True if in range or no matcher provided
-
getIsInRange
Check if a year matcher is in range for the given current year.- Parameters:
yearMatcher- The optional year matcher to checkcurrentYear- The current year to check against- Returns:
- True if in range or no matcher provided
-
isSalesSubstream
Check if a stream name represents a sales substream (domestic or import).Sales substreams are the component streams that make up the overall sales stream, representing domestic manufacturing and imported products.
- Parameters:
name- The stream name to check- Returns:
- true if the stream is domestic or import
-
getIsSalesStream
Check if a stream is a sales-related stream.A sales-related stream includes the core sales stream and its substreams (domestic and import). Optionally, the export stream can be included depending on the context of the operation being performed.
This is the centralized implementation for stream classification logic and should be used throughout the engine instead of local implementations to ensure consistent behavior.
- Parameters:
stream- The stream name to checkincludeExports- Whether to include export stream as a sales stream- Returns:
- true if the stream is a sales-related stream (sales, domestic, or import); or export if includeExports is true
-
createUnitConverterWithTotal
public static UnitConverter createUnitConverterWithTotal(ConverterStateGetter stateGetter, String stream, EngineNumber currentValue, EngineNumber initialCharge) Creates a unit converter with total values initialized.- Parameters:
stateGetter- The converter state getter from the enginestream- The stream identifier to create converter forcurrentValue- The current stream valueinitialCharge- The initial charge (for sales substreams only, can be null)- Returns:
- A configured unit converter instance
-
createUnitConverterWithTotal
Creates a unit converter with total values initialized (convenience method).- Parameters:
engine- The Engine instance to get state fromstream- The stream identifier to create converter for- Returns:
- A configured unit converter instance
-
hasUnitBasedSalesSpecifications
public static boolean hasUnitBasedSalesSpecifications(SimulationState simulationState, UseKey scope) Check if sales streams were specified in equipment units for the given scope. When streams are specified in units, certain operations need different handling (e.g., retirement affects recharge calculations, carry-over logic differs).- Parameters:
simulationState- the SimulationState instance to queryscope- the scope to check- Returns:
- true if sales streams were specified in units
-
ensurePositive
Ensures a value is positive, clamping to zero if negative.This method checks if a value would be negative and returns zero if so, otherwise returns the value unchanged. It's used to enforce constraints that prevent negative stream values when the operation being performed doesn't allow them.
- Parameters:
value- The value to check- Returns:
- The value if positive, or zero if negative
-
getDistributedRecharge
public static BigDecimal getDistributedRecharge(String streamName, EngineNumber totalRecharge, UseKey useKey, SimulationState simulationState) Gets the distributed recharge amount for a specific stream.This method distributes total recharge volume across sales streams based on their current distribution percentages. The sales stream receives 100% of the recharge (to be distributed internally), sales substreams (domestic/import) receive their proportional share, and other streams receive zero.
- Parameters:
streamName- The name of the streamtotalRecharge- The total recharge amountuseKey- The use key containing application and substancesimulationState- The simulation state to query for distribution- Returns:
- The distributed recharge amount based on stream percentages
- Throws:
IllegalArgumentException- if streamName is a sales substream but not domestic or import
-