Interface Money

All Superinterfaces:
Comparable<javax.money.MonetaryAmount>, javax.money.CurrencySupplier, javax.money.MonetaryAmount, MonetaryAmountConvertable, javax.money.NumberSupplier
All Known Subinterfaces:
CentPrecisionMoney, CentPrecisionMoneyDraft, HighPrecisionMoney, HighPrecisionMoneyDraft, TypedMoney, TypedMoneyDraft

public interface Money extends MonetaryAmountConvertable, javax.money.MonetaryAmount

Draft type that stores amounts in cent precision for the specified currency.

For storing money values in fractions of the minor unit in a currency, use HighPrecisionMoneyDraft instead.


Example to create an instance using the builder pattern

     Money money = Money.builder()
             .centAmount(0.3)
             .currencyCode("{currencyCode}")
             .build()
 
  • Method Details

    • getCentAmount

      @NotNull @NotNull Long getCentAmount()

      Amount in the smallest indivisible unit of a currency, such as:

      • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
      • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
      Returns:
      centAmount
    • getCurrencyCode

      @NotNull @NotNull String getCurrencyCode()

      Currency code compliant to ISO 4217.

      Returns:
      currencyCode
    • setCentAmount

      void setCentAmount(Long centAmount)
    • setCurrencyCode

      void setCurrencyCode(String currencyCode)
    • of

      static Money of()
    • of

      static Money of(Money template)
    • of

      static CentPrecisionMoney of(javax.money.MonetaryAmount monetaryAmount)
    • of

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

      static CentPrecisionMoneyDraft draftOf(javax.money.MonetaryAmount monetaryAmount)
    • draftOf

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

      @Nullable static Money deepCopy(@Nullable Money template)
    • builder

      static MoneyBuilder builder()
    • builder

      static MoneyBuilder builder(Money template)
    • withMoney

      default <T> T withMoney(Function<Money,T> helper)
      Specified by:
      withMoney in interface MonetaryAmountConvertable
    • toDraft

      default TypedMoneyDraft toDraft()
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<Money> typeReference()
    • createMoneyOperator

      default javax.money.MonetaryOperator createMoneyOperator()
    • getContext

      default javax.money.MonetaryContext getContext()
      Specified by:
      getContext in interface javax.money.MonetaryAmount
    • getFactory

      default javax.money.MonetaryAmountFactory<? extends javax.money.MonetaryAmount> getFactory()
      Specified by:
      getFactory in interface javax.money.MonetaryAmount
    • isGreaterThan

      default boolean isGreaterThan(javax.money.MonetaryAmount amount)
      Specified by:
      isGreaterThan in interface javax.money.MonetaryAmount
    • isGreaterThanOrEqualTo

      default boolean isGreaterThanOrEqualTo(javax.money.MonetaryAmount amount)
      Specified by:
      isGreaterThanOrEqualTo in interface javax.money.MonetaryAmount
    • isLessThan

      default boolean isLessThan(javax.money.MonetaryAmount amount)
      Specified by:
      isLessThan in interface javax.money.MonetaryAmount
    • isLessThanOrEqualTo

      default boolean isLessThanOrEqualTo(javax.money.MonetaryAmount amount)
      Specified by:
      isLessThanOrEqualTo in interface javax.money.MonetaryAmount
    • isEqualTo

      default boolean isEqualTo(javax.money.MonetaryAmount amount)
      Specified by:
      isEqualTo in interface javax.money.MonetaryAmount
    • signum

      default int signum()
      Specified by:
      signum in interface javax.money.MonetaryAmount
    • add

      default javax.money.MonetaryAmount add(javax.money.MonetaryAmount augend)
      Specified by:
      add in interface javax.money.MonetaryAmount
    • subtract

      default javax.money.MonetaryAmount subtract(javax.money.MonetaryAmount subtrahend)
      Specified by:
      subtract in interface javax.money.MonetaryAmount
    • multiply

      default javax.money.MonetaryAmount multiply(long multiplicand)
      Specified by:
      multiply in interface javax.money.MonetaryAmount
    • multiply

      default javax.money.MonetaryAmount multiply(double multiplicand)
      Specified by:
      multiply in interface javax.money.MonetaryAmount
    • multiply

      default javax.money.MonetaryAmount multiply(Number multiplicand)
      Specified by:
      multiply in interface javax.money.MonetaryAmount
    • divide

      default javax.money.MonetaryAmount divide(long divisor)
      Specified by:
      divide in interface javax.money.MonetaryAmount
    • divide

      default javax.money.MonetaryAmount divide(double divisor)
      Specified by:
      divide in interface javax.money.MonetaryAmount
    • divide

      default javax.money.MonetaryAmount divide(Number divisor)
      Specified by:
      divide in interface javax.money.MonetaryAmount
    • remainder

      default javax.money.MonetaryAmount remainder(long divisor)
      Specified by:
      remainder in interface javax.money.MonetaryAmount
    • remainder

      default javax.money.MonetaryAmount remainder(double divisor)
      Specified by:
      remainder in interface javax.money.MonetaryAmount
    • remainder

      default javax.money.MonetaryAmount remainder(Number divisor)
      Specified by:
      remainder in interface javax.money.MonetaryAmount
    • divideAndRemainder

      default javax.money.MonetaryAmount[] divideAndRemainder(long divisor)
      Specified by:
      divideAndRemainder in interface javax.money.MonetaryAmount
    • divideAndRemainder

      default javax.money.MonetaryAmount[] divideAndRemainder(double divisor)
      Specified by:
      divideAndRemainder in interface javax.money.MonetaryAmount
    • divideAndRemainder

      default javax.money.MonetaryAmount[] divideAndRemainder(Number divisor)
      Specified by:
      divideAndRemainder in interface javax.money.MonetaryAmount
    • divideToIntegralValue

      default javax.money.MonetaryAmount divideToIntegralValue(long divisor)
      Specified by:
      divideToIntegralValue in interface javax.money.MonetaryAmount
    • divideToIntegralValue

      default javax.money.MonetaryAmount divideToIntegralValue(double divisor)
      Specified by:
      divideToIntegralValue in interface javax.money.MonetaryAmount
    • divideToIntegralValue

      default javax.money.MonetaryAmount divideToIntegralValue(Number divisor)
      Specified by:
      divideToIntegralValue in interface javax.money.MonetaryAmount
    • scaleByPowerOfTen

      default javax.money.MonetaryAmount scaleByPowerOfTen(int power)
      Specified by:
      scaleByPowerOfTen in interface javax.money.MonetaryAmount
    • abs

      default javax.money.MonetaryAmount abs()
      Specified by:
      abs in interface javax.money.MonetaryAmount
    • negate

      default javax.money.MonetaryAmount negate()
      Specified by:
      negate in interface javax.money.MonetaryAmount
    • plus

      default javax.money.MonetaryAmount plus()
      Specified by:
      plus in interface javax.money.MonetaryAmount
    • stripTrailingZeros

      default javax.money.MonetaryAmount stripTrailingZeros()
      Specified by:
      stripTrailingZeros in interface javax.money.MonetaryAmount
    • compareTo

      default int compareTo(javax.money.MonetaryAmount o)
      Specified by:
      compareTo in interface Comparable<javax.money.MonetaryAmount>
    • getCurrency

      default javax.money.CurrencyUnit getCurrency()
      Specified by:
      getCurrency in interface javax.money.CurrencySupplier
    • getNumber

      default javax.money.NumberValue getNumber()
      Specified by:
      getNumber in interface javax.money.NumberSupplier
    • query

      default <R> R query(javax.money.MonetaryQuery<R> query)
      Specified by:
      query in interface javax.money.MonetaryAmount
    • with

      default javax.money.MonetaryAmount with(javax.money.MonetaryOperator operator)
      Specified by:
      with in interface javax.money.MonetaryAmount