Package com.helger.base.numeric.mutable
Class MutableBigDecimal
java.lang.Object
java.lang.Number
com.helger.base.numeric.mutable.AbstractMutableNumeric<MutableBigDecimal>
com.helger.base.numeric.mutable.MutableBigDecimal
- All Implemented Interfaces:
ICloneable<MutableBigDecimal>,IComparable<MutableBigDecimal>,INumber,IMutableNumeric<MutableBigDecimal>,IMutableObject<MutableBigDecimal>,IGenericImplTrait<MutableBigDecimal>,Serializable,Comparable<MutableBigDecimal>
Object wrapper around a
BigDecimal so that it can be passed a final object but is
mutable.- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMutableBigDecimal(double dValue) Initialize with a certain double value.MutableBigDecimal(long nValue) Initialize with a certain long value.MutableBigDecimal(@NonNull MutableBigDecimal aOther) Copy constructor.MutableBigDecimal(@NonNull BigDecimal aValue) Initialize with a certainBigDecimalvalue. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NonNull MutableBigDecimal rhs) @NonNull BigDecimaldec()Decrement by 1 and return the modified value.@NonNull BigDecimaldec(double dDelta) Decrement by the given delta and return the modified value.@NonNull BigDecimaldec(long nDelta) Decrement by the given delta and return the modified value.@NonNull BigDecimaldec(@NonNull MutableBigDecimal aDelta) Decrement by the given delta and return the modified value.@NonNull BigDecimaldec(@NonNull BigDecimal aDelta) Decrement by the given delta and return the modified value.@NonNull BigDecimaldivide(double dDivisor, int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.@NonNull BigDecimaldivide(long nDivisor, int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.@NonNull BigDecimaldivide(@NonNull MutableBigDecimal aDivisor, int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.@NonNull BigDecimaldivide(@NonNull BigDecimal aDivisor, int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.doubleReturns the value of the specified number as adouble, which may involve rounding.booleanfloatReturns the value of the specified number as afloat, which may involve rounding.@NonNull BigDecimalGet the current value and then increment by 1.@NonNull BigDecimal@NonNull MutableBigDecimalgetClone()inthashCode()@NonNull BigDecimalinc()Increment by 1 and return the modified value.@NonNull BigDecimalinc(double dDelta) Increment by the given delta and return the modified value.@NonNull BigDecimalinc(long nDelta) Increment by the given delta and return the modified value.@NonNull BigDecimalinc(@NonNull MutableBigDecimal aDelta) Increment by the given delta and return the modified value.@NonNull BigDecimalinc(@NonNull BigDecimal aDelta) Increment by the given delta and return the modified value.@NonNull BigDecimalIncrement by 1 and then get the new value.intintValue()Returns the value of the specified number as anint, which may involve rounding or truncation.booleanis0()booleanisGE0()booleanisGT0()booleanisLE0()booleanisLT0()longReturns the value of the specified number as along, which may involve rounding or truncation.@NonNull BigDecimalmultiply(double dMultiplicand) Multiply the current value by the given multiplicand.@NonNull BigDecimalmultiply(long nMultiplicand) Multiply the current value by the given multiplicand.@NonNull BigDecimalmultiply(@NonNull MutableBigDecimal aMultiplicand) Multiply the current value by the given multiplicand.@NonNull BigDecimalmultiply(@NonNull BigDecimal aMultiplicand) Multiply the current value by the given multiplicand.@NonNull EChangeset(double dDelta) Set a new value.@NonNull EChangeset(long nDelta) Set a new value.@NonNull EChangeset(@NonNull MutableBigDecimal aValue) Set a new value.@NonNull EChangeset(@NonNull BigDecimal aValue) Set a new value.toString()Methods inherited from class com.helger.base.numeric.mutable.AbstractMutableNumeric
onAfterChangeMethods inherited from class java.lang.Number
byteValue, shortValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.compare.IComparable
isEQ, isGE, isGT, isLE, isLT, isNEMethods inherited from interface com.helger.base.trait.IGenericImplTrait
thisAsTMethods inherited from interface com.helger.base.numeric.mutable.IMutableNumeric
getAsBigInteger, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsShort, isNot0Methods inherited from interface com.helger.base.numeric.INumber
byteValue, shortValue
-
Constructor Details
-
MutableBigDecimal
public MutableBigDecimal(long nValue) Initialize with a certain long value.- Parameters:
nValue- The value to be used.
-
MutableBigDecimal
public MutableBigDecimal(double dValue) Initialize with a certain double value.- Parameters:
dValue- The value to be used.
-
MutableBigDecimal
Copy constructor.- Parameters:
aOther- The object to copy from. May not benull.
-
MutableBigDecimal
Initialize with a certainBigDecimalvalue.- Parameters:
aValue- The value to be used. May not benull.
-
-
Method Details
-
getAsBigDecimal
-
doubleValue
public double doubleValue()Description copied from interface:INumberReturns the value of the specified number as adouble, which may involve rounding.- Specified by:
doubleValuein interfaceINumber- Specified by:
doubleValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
double.
-
floatValue
public float floatValue()Description copied from interface:INumberReturns the value of the specified number as afloat, which may involve rounding.- Specified by:
floatValuein interfaceINumber- Specified by:
floatValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
float.
-
intValue
public int intValue()Description copied from interface:INumberReturns the value of the specified number as anint, which may involve rounding or truncation. -
longValue
public long longValue()Description copied from interface:INumberReturns the value of the specified number as along, which may involve rounding or truncation. -
inc
Increment by 1 and return the modified value.- Returns:
- The by 1 incremented value.
-
inc
Increment by the given delta and return the modified value.- Parameters:
nDelta- The delta to add.- Returns:
- The new value after incrementing. Never
null.
-
inc
Increment by the given delta and return the modified value.- Parameters:
dDelta- The delta to add.- Returns:
- The new value after incrementing. Never
null.
-
inc
Increment by the given delta and return the modified value.- Parameters:
aDelta- The delta to add. May not benull.- Returns:
- The new value after incrementing. Never
null.
-
inc
Increment by the given delta and return the modified value.- Parameters:
aDelta- The delta to add. May not benull.- Returns:
- The new value after incrementing. Never
null.
-
dec
Decrement by 1 and return the modified value.- Returns:
- The by 1 decremented value. Never
null.
-
dec
Decrement by the given delta and return the modified value.- Parameters:
nDelta- The delta to subtract.- Returns:
- The new value after decrementing. Never
null.
-
dec
Decrement by the given delta and return the modified value.- Parameters:
dDelta- The delta to subtract.- Returns:
- The new value after decrementing. Never
null.
-
dec
Decrement by the given delta and return the modified value.- Parameters:
aDelta- The delta to subtract. May not benull.- Returns:
- The new value after decrementing. Never
null.
-
dec
Decrement by the given delta and return the modified value.- Parameters:
aDelta- The delta to subtract. May not benull.- Returns:
- The new value after decrementing. Never
null.
-
divide
public @NonNull BigDecimal divide(long nDivisor, @Nonnegative int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.- Parameters:
nDivisor- The divisor to use.nScale- The scale for the division result.eRoundingMode- The rounding mode to use. May not benull.- Returns:
- The new value after division. Never
null.
-
divide
public @NonNull BigDecimal divide(double dDivisor, @Nonnegative int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.- Parameters:
dDivisor- The divisor to use.nScale- The scale for the division result.eRoundingMode- The rounding mode to use. May not benull.- Returns:
- The new value after division. Never
null.
-
divide
public @NonNull BigDecimal divide(@NonNull MutableBigDecimal aDivisor, @Nonnegative int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.- Parameters:
aDivisor- The divisor to use. May not benull.nScale- The scale for the division result.eRoundingMode- The rounding mode to use. May not benull.- Returns:
- The new value after division. Never
null.
-
divide
public @NonNull BigDecimal divide(@NonNull BigDecimal aDivisor, @Nonnegative int nScale, @NonNull RoundingMode eRoundingMode) Divide the current value by the given divisor.- Parameters:
aDivisor- The divisor to use. May not benull.nScale- The scale for the division result.eRoundingMode- The rounding mode to use. May not benull.- Returns:
- The new value after division. Never
null.
-
multiply
Multiply the current value by the given multiplicand.- Parameters:
nMultiplicand- The multiplicand to use.- Returns:
- The new value after multiplication. Never
null.
-
multiply
Multiply the current value by the given multiplicand.- Parameters:
dMultiplicand- The multiplicand to use.- Returns:
- The new value after multiplication. Never
null.
-
multiply
Multiply the current value by the given multiplicand.- Parameters:
aMultiplicand- The multiplicand to use. May not benull.- Returns:
- The new value after multiplication. Never
null.
-
multiply
Multiply the current value by the given multiplicand.- Parameters:
aMultiplicand- The multiplicand to use. May not benull.- Returns:
- The new value after multiplication. Never
null.
-
set
Set a new value.- Parameters:
nDelta- The new value to set.- Returns:
EChange.CHANGEDif the value was changed.
-
set
Set a new value.- Parameters:
dDelta- The new value to set.- Returns:
EChange.CHANGEDif the value was changed.
-
set
Set a new value.- Parameters:
aValue- The new value to set. May not benull.- Returns:
EChange.CHANGEDif the value was changed.
-
set
Set a new value.- Parameters:
aValue- The new value to set. May not benull.- Returns:
EChange.CHANGEDif the value was changed.
-
is0
public boolean is0()- Returns:
trueif the value is 0
-
isLT0
public boolean isLT0()- Returns:
trueif the value is < 0
-
isLE0
public boolean isLE0()- Returns:
trueif the value is ≤ 0
-
isGT0
public boolean isGT0()- Returns:
trueif the value is > 0
-
isGE0
public boolean isGE0()- Returns:
trueif the value is ≥ 0
-
getAndInc
Get the current value and then increment by 1.- Returns:
- The value before incrementing. Never
null.
-
incAndGet
Increment by 1 and then get the new value.- Returns:
- The value after incrementing. Never
null.
-
compareTo
-
getClone
- Returns:
- A 100% deep-copy of the implementing class.
-
equals
-
hashCode
public int hashCode() -
toString
-