@@ -73,7 +73,7 @@ public final class RoundedMoney implements MonetaryAmount, Comparable<MonetaryAm
7373 /**
7474 * The rounding to be done.
7575 */
76- private MonetaryOperator rounding ;
76+ private final MonetaryOperator rounding ;
7777
7878
7979 /**
@@ -119,15 +119,18 @@ public RoundedMoney(Number number, CurrencyUnit currency, MonetaryContext contex
119119 this .rounding = Monetary
120120 .getRounding (RoundingQueryBuilder .of ().setScale (scale ).set (rm ).build ());
121121 }
122+ else {
123+ this .rounding = Monetary .getDefaultRounding ();
124+ }
122125 } else {
123126 b .set (mc .getRoundingMode ());
124127 b .set ("scale" , 2 );
125128 this .rounding =
126129 Monetary .getRounding (RoundingQueryBuilder .of ().set (mc ).setScale (2 ).build ());
127130 }
128- if ( this . rounding == null ) {
129- this . rounding = Monetary . getDefaultRounding ();
130- }
131+ }
132+ else {
133+ this . rounding = Monetary . getDefaultRounding ();
131134 }
132135 }
133136 b .set ("MonetaryRounding" , this .rounding );
@@ -401,12 +404,12 @@ public RoundedMoney plus() {
401404 * @see javax.money.MonetaryAmount#subtract(javax.money.MonetaryAmount)
402405 */
403406 @ Override
404- public RoundedMoney subtract (MonetaryAmount subtrahend ) {
405- MoneyUtils .checkAmountParameter (subtrahend , this .currency );
406- if (subtrahend .isZero ()) {
407+ public RoundedMoney subtract (MonetaryAmount amount ) {
408+ MoneyUtils .checkAmountParameter (amount , this .currency );
409+ if (amount .isZero ()) {
407410 return this ;
408411 }
409- return new RoundedMoney (this .number .subtract (subtrahend .getNumber ().numberValue (BigDecimal .class ),
412+ return new RoundedMoney (this .number .subtract (amount .getNumber ().numberValue (BigDecimal .class ),
410413 Optional .ofNullable (
411414 this .monetaryContext .get (MathContext .class )).orElse (MathContext .DECIMAL64 )),
412415 this .currency , this .rounding );
@@ -446,8 +449,8 @@ public RoundedMoney remainder(Number divisor) {
446449 * @see javax.money.MonetaryAmount#scaleByPowerOfTen(int)
447450 */
448451 @ Override
449- public RoundedMoney scaleByPowerOfTen (int n ) {
450- return new RoundedMoney (this .number .scaleByPowerOfTen (n ), this .currency , this .rounding );
452+ public RoundedMoney scaleByPowerOfTen (int power ) {
453+ return new RoundedMoney (this .number .scaleByPowerOfTen (power ), this .currency , this .rounding );
451454 }
452455
453456 /*
@@ -669,7 +672,7 @@ public static RoundedMoney parse(CharSequence text, MonetaryAmountFormat formatt
669672 return from (formatter .parse (text ));
670673 }
671674
672- private static ToStringMonetaryAmountFormat DEFAULT_FORMATTER = ToStringMonetaryAmountFormat
675+ private static final ToStringMonetaryAmountFormat DEFAULT_FORMATTER = ToStringMonetaryAmountFormat
673676 .of (ToStringMonetaryAmountFormatStyle .ROUNDED_MONEY );
674677
675678 /*
@@ -815,66 +818,66 @@ private void checkNumber(Number number) {
815818 }
816819
817820 @ Override
818- public RoundedMoney multiply (long amount ) {
819- if (amount == 1L ) {
821+ public RoundedMoney multiply (long multiplicand ) {
822+ if (multiplicand == 1L ) {
820823 return this ;
821824 }
822- return multiply (MoneyUtils .getBigDecimal (amount ));
825+ return multiply (MoneyUtils .getBigDecimal (multiplicand ));
823826 }
824827
825828 @ Override
826- public RoundedMoney multiply (double amount ) {
827- Money .checkNoInfinityOrNaN (amount );
828- if (amount == 1.0d ) {
829+ public RoundedMoney multiply (double multiplicand ) {
830+ Money .checkNoInfinityOrNaN (multiplicand );
831+ if (multiplicand == 1.0d ) {
829832 return this ;
830833 }
831- return multiply (MoneyUtils .getBigDecimal (amount ));
834+ return multiply (MoneyUtils .getBigDecimal (multiplicand ));
832835 }
833836
834837 @ Override
835- public RoundedMoney divide (long amount ) {
836- if (amount == 1L ) {
838+ public RoundedMoney divide (long divisor ) {
839+ if (divisor == 1L ) {
837840 return this ;
838841 }
839- return divide (MoneyUtils .getBigDecimal (amount ));
842+ return divide (MoneyUtils .getBigDecimal (divisor ));
840843 }
841844
842845 @ Override
843- public RoundedMoney divide (double amount ) {
844- if (Money .isInfinityAndNotNaN (amount )) {
846+ public RoundedMoney divide (double divisor ) {
847+ if (Money .isInfinityAndNotNaN (divisor )) {
845848 return new RoundedMoney (0L , getCurrency (), this .monetaryContext , this .rounding );
846849 }
847- if (amount == 1.0d ) {
850+ if (divisor == 1.0d ) {
848851 return this ;
849852 }
850- return divide (MoneyUtils .getBigDecimal (amount ));
853+ return divide (MoneyUtils .getBigDecimal (divisor ));
851854 }
852855
853856 @ Override
854- public RoundedMoney remainder (long amount ) {
855- return remainder (MoneyUtils .getBigDecimal (amount ));
857+ public RoundedMoney remainder (long divisor ) {
858+ return remainder (MoneyUtils .getBigDecimal (divisor ));
856859 }
857860
858861 @ Override
859- public RoundedMoney remainder (double amount ) {
860- if (Money .isInfinityAndNotNaN (amount )) {
862+ public RoundedMoney remainder (double divisor ) {
863+ if (Money .isInfinityAndNotNaN (divisor )) {
861864 return new RoundedMoney (0L , getCurrency (), this .monetaryContext , this .rounding );
862865 }
863- return remainder (MoneyUtils .getBigDecimal (amount ));
866+ return remainder (MoneyUtils .getBigDecimal (divisor ));
864867 }
865868
866869 @ Override
867- public RoundedMoney [] divideAndRemainder (long amount ) {
868- return divideAndRemainder (MoneyUtils .getBigDecimal (amount ));
870+ public RoundedMoney [] divideAndRemainder (long divisor ) {
871+ return divideAndRemainder (MoneyUtils .getBigDecimal (divisor ));
869872 }
870873
871874 @ Override
872- public RoundedMoney [] divideAndRemainder (double amount ) {
873- if (Money .isInfinityAndNotNaN (amount )) {
875+ public RoundedMoney [] divideAndRemainder (double divisor ) {
876+ if (Money .isInfinityAndNotNaN (divisor )) {
874877 RoundedMoney zero = new RoundedMoney (0L , getCurrency (), this .monetaryContext , this .rounding );
875878 return new RoundedMoney []{zero , zero };
876879 }
877- return divideAndRemainder (MoneyUtils .getBigDecimal (amount ));
880+ return divideAndRemainder (MoneyUtils .getBigDecimal (divisor ));
878881 }
879882
880883 @ Override
0 commit comments