Interface TypedMoney

All Superinterfaces:
Comparable<javax.money.MonetaryAmount>, javax.money.CurrencySupplier, javax.money.MonetaryAmount, MonetaryAmountConvertable, Money, javax.money.NumberSupplier
All Known Subinterfaces:
CentPrecisionMoney, HighPrecisionMoney

public interface TypedMoney extends Money

Base polymorphic read-only money type that stores currency in cent precision or high precision, that is in sub-cents.


Example to create a subtype instance using the builder pattern

     TypedMoney typedMoney = TypedMoney.centPrecisionBuilder()
             centAmount(0.3)
             currencyCode("{currencyCode}")
             fractionDigits(0.3)
             .build()
 
  • Method Details

    • getType

      @NotNull @NotNull MoneyType getType()

      Type of money used.

      Returns:
      type
    • getFractionDigits

      @NotNull @NotNull Integer getFractionDigits()

      Number of digits after the decimal separator.

      • For CentPrecisionMoney, it is equal to the default number of fraction digits for a currency.
      • For HighPrecisionMoney, it is greater than the default number of fraction digits for a currency.
      Returns:
      fractionDigits
    • setFractionDigits

      void setFractionDigits(Integer fractionDigits)

      Number of digits after the decimal separator.

      • For CentPrecisionMoney, it is equal to the default number of fraction digits for a currency.
      • For HighPrecisionMoney, it is greater than the default number of fraction digits for a currency.
      Parameters:
      fractionDigits - value to be set
    • deepCopy

      @Nullable static TypedMoney deepCopy(@Nullable TypedMoney template)
      factory method to create a deep copy of TypedMoney
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • centPrecisionBuilder

      static CentPrecisionMoneyBuilder centPrecisionBuilder()
      builder for centPrecision subtype
      Returns:
      builder
    • highPrecisionBuilder

      static HighPrecisionMoneyBuilder highPrecisionBuilder()
      builder for highPrecision subtype
      Returns:
      builder
    • withTypedMoney

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

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

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