Class ReplaceOperation

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

public class ReplaceOperation extends Object implements Operation
Operation that replaces a substance with another substance.

This operation calculates a replacement amount and applies it to the engine. It can optionally be limited to a specific time period using a ParsedDuring object.

  • Constructor Details

    • ReplaceOperation

      public ReplaceOperation(Operation amountOperation, String stream, String destinationSubstance)
      Create a new ReplaceOperation that applies to all years.
      Parameters:
      amountOperation - The operation that calculates the replacement amount.
      stream - The stream to replace.
      destinationSubstance - The substance to replace with.
    • ReplaceOperation

      public ReplaceOperation(Operation amountOperation, String stream, String destinationSubstance, ParsedDuring during)
      Create a new ReplaceOperation that applies to a specific time period.
      Parameters:
      amountOperation - The operation that calculates the replacement amount.
      stream - The stream to replace.
      destinationSubstance - The substance to replace with.
      during - The time period during which this operation applies.
  • Method Details

    • 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.