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