Interface Money
- All Known Subinterfaces:
CentPrecisionMoney,TypedMoney
public interface Money
Draft object to store money in cent amounts for a specific currency.
Example to create an instance using the builder pattern
Money money = Money.builder()
.centAmount(0.3)
.currencyCode("{currencyCode}")
.build()
-
Method Summary
Modifier and TypeMethodDescriptionstatic MoneyBuilderbuilder()builder factory method for Moneystatic MoneyBuildercreate builder for Money instancecopyDeep()static Moneyfactory method to create a deep copy of Money@NotNull LongAmount in the smallest indivisible unit of a currency, such as:@NotNull StringCurrency code compliant to ISO 4217.static Moneyof()factory methodstatic Moneyfactory method to create a shallow copy MoneyvoidsetCentAmount(Long centAmount) Amount in the smallest indivisible unit of a currency, such as:voidsetCurrencyCode(String currencyCode) Currency code compliant to ISO 4217.static com.fasterxml.jackson.core.type.TypeReference<Money>gives a TypeReference for usage with Jackson DataBinddefault <T> Taccessor map function
-
Method Details
-
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
Currency code compliant to ISO 4217.
- Returns:
- currencyCode
-
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
Currency code compliant to ISO 4217.
- Parameters:
currencyCode- value to be set
-
of
factory method- Returns:
- instance of Money
-
of
factory method to create a shallow copy Money- Parameters:
template- instance to be copied- Returns:
- copy instance
-
copyDeep
Money copyDeep() -
deepCopy
factory method to create a deep copy of Money- Parameters:
template- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for Money- Returns:
- builder
-
builder
create builder for Money instance- Parameters:
template- instance with prefilled values for the builder- Returns:
- builder
-
withMoney
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
-