java.lang.Object
io.github.tonywasher.joceanus.oceanus.decimal.OceanusDecimal
io.github.tonywasher.joceanus.oceanus.decimal.OceanusUnits
All Implemented Interfaces:
Comparable<OceanusDecimal>

public class OceanusUnits extends OceanusDecimal
Represents a Units object.
  • Field Details

    • NUM_DECIMALS

      protected static final int NUM_DECIMALS
      Standard number of decimals for Units.
      See Also:
  • Constructor Details

    • OceanusUnits

      public OceanusUnits()
      Construct a new Units.
    • OceanusUnits

      public OceanusUnits(OceanusUnits pUnits)
      Construct a new Units by copying another units.
      Parameters:
      pUnits - the Units to copy
    • OceanusUnits

      public OceanusUnits(String pSource)
      Constructor for units from a decimal string.
      Parameters:
      pSource - The source decimal string
      Throws:
      IllegalArgumentException - on invalidly formatted argument
    • OceanusUnits

      public OceanusUnits(byte[] pBuffer)
      Create the units from a byte array.
      Parameters:
      pBuffer - the buffer
  • Method Details

    • getWholeUnits

      public static OceanusUnits getWholeUnits(long pValue)
      Construct a new Units by setting the value explicitly.
      Parameters:
      pValue - the unscaled value
      Returns:
      the new Rate
    • addUnits

      public void addUnits(OceanusUnits pValue)
      Add units to the value.
      Parameters:
      pValue - The units to add to this one.
    • subtractUnits

      public void subtractUnits(OceanusUnits pValue)
      Subtract units from the value.
      Parameters:
      pValue - The units to subtract from this one.
    • addValue

      public void addValue(OceanusDecimal pValue)
      Description copied from class: OceanusDecimal
      Add a Decimal to the value. The value of this Decimal is updated and the scale is maintained.
      Overrides:
      addValue in class OceanusDecimal
      Parameters:
      pValue - The Decimal to add to this one.
    • subtractValue

      public void subtractValue(OceanusDecimal pValue)
      Description copied from class: OceanusDecimal
      Subtract a Decimal from the value. The value of this Decimal is updated and the scale is maintained.
      Overrides:
      subtractValue in class OceanusDecimal
      Parameters:
      pValue - The decimal to subtract from this one.
    • valueAtPrice

      public OceanusMoney valueAtPrice(OceanusPrice pPrice)
      calculate the value of these units at a given price.
      Parameters:
      pPrice - the per unit price
      Returns:
      the calculated value