Package org.kigalisim.engine.support
Class DisplaceExecutor
java.lang.Object
org.kigalisim.engine.support.DisplaceExecutor
Executor for displacement operations in cap, floor, and recover commands.
-
Constructor Summary
ConstructorsConstructorDescriptionDisplaceExecutor(Engine engine) Creates a new DisplaceExecutor for the given engine. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(String stream, EngineNumber amount, BigDecimal changeAmount, String displaceTarget, DisplacementType displacementType) Executes a displacement operation to offset a change in one stream with a change in another.
-
Constructor Details
-
DisplaceExecutor
Creates a new DisplaceExecutor for the given engine.- Parameters:
engine- The Engine instance to operate on
-
-
Method Details
-
execute
public void execute(String stream, EngineNumber amount, BigDecimal changeAmount, String displaceTarget, DisplacementType displacementType) Executes a displacement operation to offset a change in one stream with a change in another.Displacement allows changes in one stream to be balanced by inverse changes in another stream or substance. This is used by cap, floor, and recover operations to enable complex policy scenarios like:
- Capping domestic manufacturing while increasing imports (stream displacement)
- Phasing down a high-GWP substance while ramping up a low-GWP alternative (substance displacement)
- Crediting recycled material recovery against virgin material consumption
The method handles three distinct cases:
- Automatic recycling displacement: When recovering material to the sales stream, automatically adds the recycled volume to sales before applying targeted displacement. This maintains material balance in the system.
- Equipment-unit displacement: When the operation uses equipment units, converts the volume change back to units in the source substance, then applies the same number of units to the destination (with destination-specific initial charge for substance displacement).
- Volume displacement: When the operation uses volume units (kg/mt), applies the same substance volume to the destination.
- Parameters:
stream- The stream identifier being modified (e.g., "domestic", "import", "sales")amount- The amount used for the original operation (determines units vs volume mode)changeAmount- The actual change amount in kg (negative for reductions)displaceTarget- The target for displacement (stream name or substance name), or nulldisplacementType- The type of displacement (EQUIVALENT, BY_VOLUME, or BY_UNITS)- Throws:
IllegalArgumentException- if attempting to displace stream to itself
-