Interface TypedMoney
- All Superinterfaces:
Comparable<javax.money.MonetaryAmount>
,javax.money.CurrencySupplier
,javax.money.MonetaryAmount
,MonetaryAmountConvertable
,Money
,javax.money.NumberSupplier
- All Known Subinterfaces:
CentPrecisionMoney
,HighPrecisionMoney
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 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()
Type of money used.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
Type of money used.
- Returns:
- type
-
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
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
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
default javax.money.MonetaryOperator createMoneyOperator()- Specified by:
createMoneyOperator
in interfaceMoney
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-