Class RetireExactOperation

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

public class RetireExactOperation extends Object implements Operation
Operation backing the retire N year old exact shortcut.

Delegates the actual retirement to the existing units-based retirement path once the age-N cohort's size is computed by amountOperation, optionally replacing retired equipment to maintain population the same way RetireWithReplacementOperation and RetireWeibullOperation do. Kept as its own operation type rather than reusing RetireOperation / RetireWithReplacementOperation directly so that ProgramValidator can flag it when combined with a directly-set priorEquipment, whose age this shortcut's sales-history lookup cannot see, unless assumingNew is set.

  • Constructor Summary

    Constructors
    Constructor
    Description
    RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement)
    Create a new RetireExactOperation that applies to all years.
    RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement, ParsedDuring during)
    Create a new RetireExactOperation that applies to a specific time period.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Execute the exact retire operation on the given push-down machine.
    boolean
    Whether prior equipment is treated as a pseudo-cohort assumed to have entered service when the simulation began.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RetireExactOperation

      public RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement)
      Create a new RetireExactOperation that applies to all years.
      Parameters:
      amountOperation - The operation that calculates the age-N cohort size to retire.
      ageYears - The exact age in years at which the cohort retires.
      assumingNew - Whether prior equipment should be treated as a pseudo-cohort assumed to have entered service when the simulation began (the assuming new modifier).
      withReplacement - Whether retired equipment should be replaced to maintain population.
    • RetireExactOperation

      public RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement, ParsedDuring during)
      Create a new RetireExactOperation that applies to a specific time period.
      Parameters:
      amountOperation - The operation that calculates the age-N cohort size to retire.
      ageYears - The exact age in years at which the cohort retires.
      assumingNew - Whether prior equipment should be treated as a pseudo-cohort assumed to have entered service when the simulation began (the assuming new modifier).
      withReplacement - Whether retired equipment should be replaced to maintain population.
      during - The time period during which this operation applies.
  • Method Details

    • getAssumingNew

      public boolean getAssumingNew()
      Whether prior equipment is treated as a pseudo-cohort assumed to have entered service when the simulation began.
      Returns:
      true if the assuming new modifier is set
    • execute

      public void execute(PushDownMachine machine)
      Execute the exact retire operation on the given push-down machine.

      Evaluates the amount operation to get the size of the age-N cohort, builds a year matcher from the optional during clause, and checks if this operation should execute in the current year. If the year is in range, validates that retire commands are not mixed with and without replacement in the same step. With assuming new, any priorEquipment not explained by tracked sales cohorts is added to the retirement amount in the one year the simulation reaches the given age (as if that stock had entered service when the simulation began). The cohort is then retired, replacing it to maintain population when withReplacement is set.

      Specified by:
      execute in interface Operation
      Parameters:
      machine - The push-down machine context for evaluating operations.