Interface HighPrecisionMoneyDraft
- All Superinterfaces:
Comparable<javax.money.MonetaryAmount>
,javax.money.CurrencySupplier
,Draft<HighPrecisionMoneyDraft>
,javax.money.MonetaryAmount
,MonetaryAmountConvertable
,Money
,javax.money.NumberSupplier
,TypedMoneyDraft
Draft object to store money as a fraction of the smallest indivisible unit for a specific currency.
Example to create an instance using the builder pattern
HighPrecisionMoneyDraft highPrecisionMoneyDraft = HighPrecisionMoneyDraft.builder()
.currencyCode("{currencyCode}")
.fractionDigits(0.3)
.preciseAmount(0.3)
.build()
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
discriminator value for HighPrecisionMoneyDraft -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
builder factory method for HighPrecisionMoneyDraftbuilder
(HighPrecisionMoneyDraft template) create builder for HighPrecisionMoneyDraft instancedefault javax.money.MonetaryOperator
static HighPrecisionMoneyDraft
deepCopy
(HighPrecisionMoneyDraft template) factory method to create a deep copy of HighPrecisionMoneyDraftAmount in the smallest indivisible unit of a currency.@NotNull Integer
Number of fraction digits for a specified high precision money.@NotNull Long
Amount in 1 / (10 ^fractionDigits
) of a currency.static HighPrecisionMoneyDraft
of()
factory methodstatic HighPrecisionMoneyDraft
of
(HighPrecisionMoney template) static HighPrecisionMoneyDraft
of
(HighPrecisionMoneyDraft template) factory method to create a shallow copy HighPrecisionMoneyDraftstatic HighPrecisionMoneyDraft
of
(javax.money.MonetaryAmount monetaryAmount, int fractionDigits) void
setCentAmount
(Long centAmount) Amount in the smallest indivisible unit of a currency.void
setFractionDigits
(Integer fractionDigits) Number of fraction digits for a specified high precision money.void
setPreciseAmount
(Long preciseAmount) Amount in 1 / (10 ^fractionDigits
) of a currency.static com.fasterxml.jackson.core.type.TypeReference<HighPrecisionMoneyDraft>
gives a TypeReference for usage with Jackson DataBinddefault <T> T
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, getContext, getCurrency, getCurrencyCode, getFactory, getNumber, isEqualTo, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, multiply, multiply, multiply, negate, plus, query, remainder, remainder, remainder, scaleByPowerOfTen, setCurrencyCode, signum, stripTrailingZeros, subtract, toDraft, with, withMoney
Methods inherited from interface com.commercetools.api.models.common.TypedMoneyDraft
getType, withTypedMoneyDraft
-
Field Details
-
HIGH_PRECISION
discriminator value for HighPrecisionMoneyDraft- See Also:
-
-
Method Details
-
getFractionDigits
Number of fraction digits for a specified high precision money. It must be greater than the default number of fraction digits for the specified currency.
- Specified by:
getFractionDigits
in interfaceTypedMoneyDraft
- Returns:
- fractionDigits
-
getPreciseAmount
Amount in 1 / (10 ^
fractionDigits
) of a currency.- Returns:
- preciseAmount
-
getCentAmount
Long getCentAmount()Amount in the smallest indivisible unit of a currency. This field is optional for high precision. If provided, it is checked for validity. Example:
A Price of 1.015 USD can be rounded either to 1.01 USD or 1.02 USD. If it lies outside of this range, an error message stating that centAmount must be rounded correctly will be returned.
If
centAmount
is not provided, the API calculates the value automatically using the default rounding mode half even.- Specified by:
getCentAmount
in interfaceMoney
- Specified by:
getCentAmount
in interfaceTypedMoneyDraft
- Returns:
- centAmount
-
setFractionDigits
Number of fraction digits for a specified high precision money. It must be greater than the default number of fraction digits for the specified currency.
- Specified by:
setFractionDigits
in interfaceTypedMoneyDraft
- Parameters:
fractionDigits
- value to be set
-
setPreciseAmount
Amount in 1 / (10 ^
fractionDigits
) of a currency.- Parameters:
preciseAmount
- value to be set
-
setCentAmount
Amount in the smallest indivisible unit of a currency. This field is optional for high precision. If provided, it is checked for validity. Example:
A Price of 1.015 USD can be rounded either to 1.01 USD or 1.02 USD. If it lies outside of this range, an error message stating that centAmount must be rounded correctly will be returned.
If
centAmount
is not provided, the API calculates the value automatically using the default rounding mode half even.- Specified by:
setCentAmount
in interfaceMoney
- Specified by:
setCentAmount
in interfaceTypedMoneyDraft
- Parameters:
centAmount
- value to be set
-
of
factory method- Returns:
- instance of HighPrecisionMoneyDraft
-
of
factory method to create a shallow copy HighPrecisionMoneyDraft- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
deepCopy
factory method to create a deep copy of HighPrecisionMoneyDraft- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for HighPrecisionMoneyDraft- Returns:
- builder
-
builder
create builder for HighPrecisionMoneyDraft instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-
withHighPrecisionMoneyDraft
accessor map function- Type Parameters:
T
- mapped type- Parameters:
helper
- function to map the object- Returns:
- mapped value
-
of
-
of
-
createMoneyOperator
default javax.money.MonetaryOperator createMoneyOperator()- Specified by:
createMoneyOperator
in interfaceMoney
- Specified by:
createMoneyOperator
in interfaceTypedMoneyDraft
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-