Class CapOperation

java.lang.Object
org.kigalisim.lang.operation.CapOperation
All Implemented Interfaces:
Operation

public class CapOperation extends Object implements Operation
Operation that caps a stream value to a specified maximum and optionally displaces the excess.

This operation calculates a value and caps a specified stream in the engine to that maximum. The excess can optionally be displaced to another stream. It can also optionally be limited to a specific time period using a ParsedDuring object.

  • Constructor Details

    • CapOperation

      public CapOperation(String stream, Operation valueOperation)
      Create a new CapOperation that applies to all years.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
    • CapOperation

      public CapOperation(String stream, Operation valueOperation, String displaceTarget)
      Create a new CapOperation that applies to all years with displacement.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
      displaceTarget - The name of the stream to displace excess to.
    • CapOperation

      public CapOperation(String stream, Operation valueOperation, String displaceTarget, DisplacementType displacementType)
      Create a new CapOperation that applies to all years with displacement and displacement type.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
      displaceTarget - The name of the stream to displace excess to.
      displacementType - The type of displacement to use.
    • CapOperation

      public CapOperation(String stream, Operation valueOperation, ParsedDuring during)
      Create a new CapOperation that applies to a specific time period.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
      during - The time period during which this operation applies.
    • CapOperation

      public CapOperation(String stream, Operation valueOperation, String displaceTarget, ParsedDuring during)
      Create a new CapOperation that applies to a specific time period with displacement.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
      displaceTarget - The name of the stream to displace excess to.
      during - The time period during which this operation applies.
    • CapOperation

      public CapOperation(String stream, Operation valueOperation, String displaceTarget, ParsedDuring during, DisplacementType displacementType)
      Create a new CapOperation that applies to a specific time period with displacement and displacement type.
      Parameters:
      stream - The name of the stream to cap.
      valueOperation - The operation that calculates the maximum value.
      displaceTarget - The name of the stream to displace excess to.
      during - The time period during which this operation applies.
      displacementType - The type of displacement to use.
  • Method Details

    • getDisplacementType

      public DisplacementType getDisplacementType()
      Get the displacement type.
      Returns:
      The displacement type.
    • execute

      public void execute(PushDownMachine machine)
      Execute the calculation and leave the result at the top of the stack.
      Specified by:
      execute in interface Operation
      Parameters:
      machine - The machine in which to execute the calculation if needed.
    • getStaticSemantics

      public OperationStaticSemantics getStaticSemantics()
      Get a record describing this operation's semantics.

      Get a record describing this operation's semantics that are inferrable from its static expression in code. In other words, properties and effects which do not require inspection at time of executing the operation.

      Specified by:
      getStaticSemantics in interface Operation
      Returns:
      Inference of common static properties found for this operation.