Interface HighPrecisionMoneyDraft

All Superinterfaces:
Comparable<javax.money.MonetaryAmount>, javax.money.CurrencySupplier, Draft<HighPrecisionMoneyDraft>, javax.money.MonetaryAmount, MonetaryAmountConvertable, Money, javax.money.NumberSupplier, TypedMoneyDraft

public interface HighPrecisionMoneyDraft extends TypedMoneyDraft, Draft<HighPrecisionMoneyDraft>

Draft object to store money as a fraction of the smallest indivisible unit for a specific currency.


Example to create an instance using the builder pattern

     HighPrecisionMoneyDraft highPrecisionMoneyDraft = HighPrecisionMoneyDraft.builder()
             .currencyCode("{currencyCode}")
             .fractionDigits(0.3)
             .preciseAmount(0.3)
             .build()
 
  • Field Details

  • Method Details

    • getFractionDigits

      @NotNull @NotNull Integer getFractionDigits()

      Number of fraction digits for a specified high precision money. It must be greater than the default number of fraction digits for the specified currency.

      Specified by:
      getFractionDigits in interface TypedMoneyDraft
      Returns:
      fractionDigits
    • getPreciseAmount

      @NotNull @NotNull Long getPreciseAmount()

      Amount in 1 / (10 ^ fractionDigits) of a currency.

      Returns:
      preciseAmount
    • getCentAmount

      Long getCentAmount()

      Amount in the smallest indivisible unit of a currency. This field is optional for high precision. If provided, it is checked for validity. Example:

      A Price of 1.015 USD can be rounded either to 1.01 USD or 1.02 USD. If it lies outside of this range, an error message stating that centAmount must be rounded correctly will be returned.

      If centAmount is not provided, the API calculates the value automatically using the default rounding mode half even.

      Specified by:
      getCentAmount in interface Money
      Specified by:
      getCentAmount in interface TypedMoneyDraft
      Returns:
      centAmount
    • setFractionDigits

      void setFractionDigits(Integer fractionDigits)

      Number of fraction digits for a specified high precision money. It must be greater than the default number of fraction digits for the specified currency.

      Specified by:
      setFractionDigits in interface TypedMoneyDraft
      Parameters:
      fractionDigits - value to be set
    • setPreciseAmount

      void setPreciseAmount(Long preciseAmount)

      Amount in 1 / (10 ^ fractionDigits) of a currency.

      Parameters:
      preciseAmount - value to be set
    • setCentAmount

      void setCentAmount(Long centAmount)

      Amount in the smallest indivisible unit of a currency. This field is optional for high precision. If provided, it is checked for validity. Example:

      A Price of 1.015 USD can be rounded either to 1.01 USD or 1.02 USD. If it lies outside of this range, an error message stating that centAmount must be rounded correctly will be returned.

      If centAmount is not provided, the API calculates the value automatically using the default rounding mode half even.

      Specified by:
      setCentAmount in interface Money
      Specified by:
      setCentAmount in interface TypedMoneyDraft
      Parameters:
      centAmount - value to be set
    • of

      factory method
      Returns:
      instance of HighPrecisionMoneyDraft
    • of

      factory method to create a shallow copy HighPrecisionMoneyDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      factory method to create a deep copy of HighPrecisionMoneyDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      builder factory method for HighPrecisionMoneyDraft
      Returns:
      builder
    • builder

      create builder for HighPrecisionMoneyDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withHighPrecisionMoneyDraft

      default <T> T withHighPrecisionMoneyDraft(Function<HighPrecisionMoneyDraft,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • of

      static HighPrecisionMoneyDraft of(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • of

    • createMoneyOperator

      default javax.money.MonetaryOperator createMoneyOperator()
      Specified by:
      createMoneyOperator in interface Money
      Specified by:
      createMoneyOperator in interface TypedMoneyDraft
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<HighPrecisionMoneyDraft> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference