@Deprecated public final class PrecisionScaleRoundedOperator extends Object implements javax.money.MonetaryOperator
This implementation uses a scale and RoundingMode and precision to does the rounding operations. The implementation will use both the scale and precision, in other words, the number of digits to the right of the decimal point and the number of digits.
The derived class will implements the RoundedMoney with this rounding monetary operator
int scale = 3;
int precision = 5;
MathContext mathContext = new MathContext(precision, RoundingMode.HALF_EVEN);
MonetaryOperator monetaryOperator = PrecisionScaleRoundedOperator.of(scale, mathContext);
CurrencyUnit real = Monetary.getCurrency("BRL");
MonetaryAmount money = Money.of(BigDecimal.valueOf(35.34567), real);
MonetaryAmount result = monetaryOperator.apply(money); // BRL 35.346
Case the parameter in MonetaryOperator.apply(MonetaryAmount) be null, the apply will return a NullPointerException
PrecisionScaleRoundedOperator#of(int, MathContext)},
RoundedMoney},
MonetaryOperator},
BigDecimal#scale()},
MathContext},
BigDecimal#precision()}| Modifier and Type | Method and Description |
|---|---|
javax.money.MonetaryAmount |
apply(javax.money.MonetaryAmount amount)
Deprecated.
|
MathContext |
getMathContext()
Deprecated.
|
int |
getScale()
Deprecated.
|
static PrecisionScaleRoundedOperator |
of(int scale,
MathContext mathContext)
Deprecated.
Creates the rounded Operator from scale and roundingMode
|
String |
toString()
Deprecated.
|
public static PrecisionScaleRoundedOperator of(int scale, MathContext mathContext)
mathContext - MonetaryOperator using the scale and RoundingMode used in parameterNullPointerException - when the MathContext is nullIllegalArgumentException - if MathContext.getPrecision() is lesser than zeroIllegalArgumentException - if MathContext.getRoundingMode() is RoundingMode.UNNECESSARYRoundingMode}public javax.money.MonetaryAmount apply(javax.money.MonetaryAmount amount)
apply in interface javax.money.MonetaryOperatorpublic int getScale()
public MathContext getMathContext()
Copyright © 2012-2016 JavaMoney. All Rights Reserved.