Class EngineNumber

java.lang.Object
org.kigalisim.engine.number.EngineNumber

public class EngineNumber extends Object
Representation of a number with units within the engine.

This class encapsulates a numeric value (using BigDecimal for precision) and its associated units string. It provides methods to access the value, units, and check for specific unit types.

  • Constructor Details

    • EngineNumber

      public EngineNumber(BigDecimal value, String units)
      Create a new number with units.
      Parameters:
      value - The numeric value as a BigDecimal
      units - The units to associate with this value like "kg"
    • EngineNumber

      public EngineNumber(double value, String units)
      Create a new number with units from a double value.

      This constructor converts the double to BigDecimal for internal storage.

      Parameters:
      value - The numeric value as a double
      units - The units to associate with this value like "kg"
  • Method Details

    • getValue

      public BigDecimal getValue()
      Get the value of this number.
      Returns:
      Value as a BigDecimal
    • getUnits

      public String getUnits()
      Get the units associated with this number.
      Returns:
      The units as a string like "mt"
    • hasEquipmentUnits

      public boolean hasEquipmentUnits()
      Check if this number has equipment units.
      Returns:
      true if the units represent equipment units (start with "unit")
    • toString

      public String toString()
      Return a string representation of this number with its value and units.
      Overrides:
      toString in class Object
      Returns:
      String representation in the format "value units"