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
FieldsModifier and TypeFieldDescriptionstatic final Stringdiscriminator value for HighPrecisionMoneyDraft -
Method Summary
Modifier and TypeMethodDescriptionbuilder()builder factory method for HighPrecisionMoneyDraftbuilder(HighPrecisionMoneyDraft template) create builder for HighPrecisionMoneyDraft instancecopyDeep()default javax.money.MonetaryOperatorstatic HighPrecisionMoneyDraftdeepCopy(HighPrecisionMoneyDraft template) factory method to create a deep copy of HighPrecisionMoneyDraftAmount in the smallest indivisible unit of a currency.@NotNull IntegerNumber of fraction digits for a specified high precision money.@NotNull LongAmount in 1 / (10 ^fractionDigits) of a currency.static HighPrecisionMoneyDraftof()factory methodstatic HighPrecisionMoneyDraftof(HighPrecisionMoney template) static HighPrecisionMoneyDraftof(HighPrecisionMoneyDraft template) factory method to create a shallow copy HighPrecisionMoneyDraftstatic HighPrecisionMoneyDraftof(javax.money.MonetaryAmount monetaryAmount, int fractionDigits) voidsetCentAmount(Long centAmount) Amount in the smallest indivisible unit of a currency.voidsetFractionDigits(Integer fractionDigits) Number of fraction digits for a specified high precision money.voidsetPreciseAmount(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> Taccessor map functionMethods inherited from interface javax.money.MonetaryAmount
isNegative, isNegativeOrZero, isPositive, isPositiveOrZero, isZeroMethods inherited from interface com.commercetools.api.models.common.MonetaryAmountConvertable
toMonetaryAmountMethods 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, withMoneyMethods 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:
getFractionDigitsin 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
centAmountis not provided, the API calculates the value automatically using the default rounding mode half even.- Specified by:
getCentAmountin interfaceMoney- Specified by:
getCentAmountin 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:
setFractionDigitsin 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
centAmountis not provided, the API calculates the value automatically using the default rounding mode half even.- Specified by:
setCentAmountin interfaceMoney- Specified by:
setCentAmountin 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
-
copyDeep
HighPrecisionMoneyDraft copyDeep()- Specified by:
copyDeepin interfaceTypedMoneyDraft
-
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:
createMoneyOperatorin interfaceMoney- Specified by:
createMoneyOperatorin interfaceTypedMoneyDraft
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-