Interface TypedMoney
- All Known Subinterfaces:
HighPrecisionMoney,Money
Example to create a subtype instance using the builder pattern
TypedMoney typedMoney = TypedMoney.highPrecisionBuilder()
centAmount(0.3)
currencyCode("{currencyCode}")
preciseAmount(0.3)
.build()
-
Method Summary
Modifier and TypeMethodDescriptionstatic MoneyBuilderbuilder for centPrecision subtypecopyDeep()static TypedMoneydeepCopy(TypedMoney template) factory method to create a deep copy of TypedMoney@NotNull LongAmount in the smallest indivisible unit of a currency, such as:@NotNull StringThe currency code compliant to ISO 4217.The number of fraction digits of the money value.@NotNull MoneyTypegetType()The type of money.static HighPrecisionMoneyBuilderbuilder for highPrecision subtypevoidsetCentAmount(Long centAmount) Amount in the smallest indivisible unit of a currency, such as:voidsetCurrencyCode(String currencyCode) The currency code compliant to ISO 4217.voidsetFractionDigits(Integer fractionDigits) The number of fraction digits of the money value.static com.fasterxml.jackson.core.type.TypeReference<TypedMoney>gives a TypeReference for usage with Jackson DataBinddefault <T> TwithTypedMoney(Function<TypedMoney, T> helper) accessor map function
-
Method Details
-
getType
The type of money. The
centPrecisiontype is used for currencies with minor units, such as EUR and USD. ThehighPrecisiontype is used for currencies without minor units, such as JPY.- Returns:
- type
-
getFractionDigits
Integer getFractionDigits()The number of fraction digits of the money value. This is used to determine how many digits are after the decimal point. For example, for EUR and USD, this is
2, and for JPY, this is0.- Returns:
- fractionDigits
-
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
- Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as
-
getCurrencyCode
The currency code compliant to ISO 4217.
- Returns:
- currencyCode
-
setFractionDigits
The number of fraction digits of the money value. This is used to determine how many digits are after the decimal point. For example, for EUR and USD, this is
2, and for JPY, this is0.- Parameters:
fractionDigits- value to be set
-
setCentAmount
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).
- Parameters:
centAmount- value to be set
- Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as
-
setCurrencyCode
The currency code compliant to ISO 4217.
- Parameters:
currencyCode- value to be set
-
copyDeep
TypedMoney copyDeep() -
deepCopy
factory method to create a deep copy of TypedMoney- Parameters:
template- instance to be copied- Returns:
- copy instance
-
highPrecisionBuilder
builder for highPrecision subtype- Returns:
- builder
-
centPrecisionBuilder
builder for centPrecision subtype- Returns:
- builder
-
withTypedMoney
accessor map function- Type Parameters:
T- mapped type- Parameters:
helper- function to map the object- Returns:
- mapped value
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-