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

public class OceanusRate extends OceanusDecimal
Represents a Rate object.
  • Field Details

    • NUM_DECIMALS

      protected static final int NUM_DECIMALS
      Standard number of decimals for Rate.
      See Also:
    • RATE_ONEHUNDREDPERCENT

      public static final OceanusRate RATE_ONEHUNDREDPERCENT
      One hundred percent.
  • Constructor Details

    • OceanusRate

      protected OceanusRate()
      Construct a new Rate.
    • OceanusRate

      public OceanusRate(OceanusRate pRate)
      Construct a new Rate by copying another rate.
      Parameters:
      pRate - the Rate to copy
    • OceanusRate

      public OceanusRate(OceanusDecimal pFirst, OceanusDecimal pSecond)
      Construct a new Ratio by the ratio between two decimals.
      Parameters:
      pFirst - the first decimal
      pSecond - the second decimal
    • OceanusRate

      public OceanusRate(OceanusRatio pRatio)
      Construct a new Rate from a ratio.
      Parameters:
      pRatio - the Ratio
    • OceanusRate

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

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

    • getWholePercentage

      public static OceanusRate getWholePercentage(long pValue)
      Construct a new Rate by setting the value explicitly.
      Parameters:
      pValue - the unscaled value of a whole percentage (e.g. 2 = 2%)
      Returns:
      the new Rate
    • getWholePermille

      public static OceanusRate getWholePermille(long pValue)
      Construct a new Rate by setting the value explicitly.
      Parameters:
      pValue - the unscaled value of a whole percentage (e.g. 25 = 2.5%)
      Returns:
      the new Rate
    • getTenthPermille

      public static OceanusRate getTenthPermille(long pValue)
      Construct a new Rate by setting the value explicitly.
      Parameters:
      pValue - the unscaled value of a whole percentage (e.g. 25 = 0.25%)
      Returns:
      the new Rate
    • getRemainingRate

      public OceanusRate getRemainingRate()
      Obtain remaining rate of this rate (i.e. 100% - this rate).
      Returns:
      the remaining rate
    • getInverseRatio

      public OceanusRatio getInverseRatio()
      Obtain inverse ratio of this rate (i.e. 100%/this rate).
      Returns:
      the inverse ratio
    • 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.