Interface TypedMoney
- All Superinterfaces:
Comparable<javax.money.MonetaryAmount>
,javax.money.CurrencySupplier
,javax.money.MonetaryAmount
,MonetaryAmountConvertable
,Money
,javax.money.NumberSupplier
- All Known Subinterfaces:
CentPrecisionMoney
,HighPrecisionMoney
- All Known Implementing Classes:
CentPrecisionMoneyImpl
,HighPrecisionMoneyImpl
,TypedMoneyImpl
Base polymorphic read-only Money type which is stored in cent precision or high precision. The actual type is determined by the type
field.
Example to create a subtype instance using the builder pattern
TypedMoney typedMoney = TypedMoney.centPrecisionBuilder()
centAmount(0.3)
currencyCode("{currencyCode}")
fractionDigits(0.3)
.build()
-
Method Summary
Modifier and TypeMethodDescriptionstatic CentPrecisionMoneyBuilder
builder for centPrecision subtypedefault javax.money.MonetaryOperator
static TypedMoney
deepCopy
(TypedMoney template) factory method to create a deep copy of TypedMoney@NotNull Integer
Number of digits after the decimal separator:@NotNull MoneyType
getType()
MoneyType supports two different values, one for amounts in cent precision and another one for sub-cent amounts up to 20 fraction digits.static HighPrecisionMoneyBuilder
builder for highPrecision subtypevoid
setFractionDigits
(Integer fractionDigits) Number of digits after the decimal separator:static com.fasterxml.jackson.core.type.TypeReference<TypedMoney>
gives a TypeReference for usage with Jackson DataBinddefault <T> T
withTypedMoney
(Function<TypedMoney, T> helper) accessor map functionMethods inherited from interface javax.money.MonetaryAmount
isNegative, isNegativeOrZero, isPositive, isPositiveOrZero, isZero
Methods inherited from interface com.commercetools.api.models.common.MonetaryAmountConvertable
toMonetaryAmount
Methods inherited from interface com.commercetools.api.models.common.Money
abs, add, compareTo, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideAndRemainder, divideToIntegralValue, divideToIntegralValue, divideToIntegralValue, getCentAmount, getContext, getCurrency, getCurrencyCode, getFactory, getNumber, isEqualTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, multiply, multiply, multiply, negate, plus, query, remainder, remainder, remainder, scaleByPowerOfTen, setCentAmount, setCurrencyCode, signum, stripTrailingZeros, subtract, toDraft, with, withMoney
-
Method Details
-
getType
MoneyType supports two different values, one for amounts in cent precision and another one for sub-cent amounts up to 20 fraction digits.
- Returns:
- type
-
getFractionDigits
Number of digits after the decimal separator:
- Equal to the default number of fraction digits for a currency in CentPrecisionMoney.
- Greater than the default number of fraction digits for a currency in HighPrecisionMoney.
- Returns:
- fractionDigits
-
setFractionDigits
Number of digits after the decimal separator:
- Equal to the default number of fraction digits for a currency in CentPrecisionMoney.
- Greater than the default number of fraction digits for a currency in HighPrecisionMoney.
- Parameters:
fractionDigits
- value to be set
-
deepCopy
factory method to create a deep copy of TypedMoney- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
centPrecisionBuilder
builder for centPrecision subtype- Returns:
- builder
-
highPrecisionBuilder
builder for highPrecision subtype- Returns:
- builder
-
withTypedMoney
accessor map function- Type Parameters:
T
- mapped type- Parameters:
helper
- function to map the object- Returns:
- mapped value
-
createMoneyOperator
- Specified by:
createMoneyOperator
in interfaceMoney
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-