S
- the scale metrics type associated with this Decimalpublic final class GenericMutableDecimal<S extends ScaleMetrics> extends AbstractMutableDecimal<S,GenericMutableDecimal<S>> implements Cloneable
MutableDecimal
implemented in a
generic way, that is, different instances can have different scales. In
contrast the classes defined in the mutable
package have have no
generic parameter as they have a fixed scale per class.Constructor and Description |
---|
GenericMutableDecimal(Decimal<S> decimal)
Creates a new
GenericMutableDecimal with the same value and scale
as the given decimal argument. |
GenericMutableDecimal(S scaleMetrics)
Creates a new
GenericMutableDecimal with value zero. |
GenericMutableDecimal(S scaleMetrics,
long unscaledValue)
Creates a new
GenericMutableDecimal with the scale specified by
the given scaleMetrics argument. |
Modifier and Type | Method and Description |
---|---|
GenericMutableDecimal<S> |
clone()
Returns a clone of this mutable Decimal numerically identical to this
value.
|
protected GenericMutableDecimal<S> |
create(long unscaled)
Returns a new
Decimal whose value is
(unscaled × 10-scale). |
protected GenericMutableDecimal<S>[] |
createArray(int length)
Returns a new
Decimal array of the specified length . |
GenericDecimalFactory<S> |
getFactory()
Returns the factory that can be used to create other Decimal values of the same scale as
this Decimal. |
int |
getScale()
Returns the scale associated with this Decimal.
|
S |
getScaleMetrics()
Returns the metrics associated with the scale of this Decimal.
|
protected GenericMutableDecimal<S> |
self()
Returns
this decimal value as concrete implementation subtype. |
GenericImmutableDecimal<S> |
toImmutableDecimal()
If this
Decimal value is already an ImmutableDecimal it is simply returned. |
GenericMutableDecimal<S> |
toMutableDecimal()
If this
Decimal value is already a MutableDecimal it is simply returned. |
static <S extends ScaleMetrics> |
valueOf(Decimal<S> decimal)
Creates and returns a new
GenericMutableDecimal with the same
value and scale as the given decimal argument. |
static GenericMutableDecimal<?> |
valueOfUnscaled(int scale,
long unscaled)
Creates and returns a new
GenericMutableDecimal with the
specified scale and value. |
static <S extends ScaleMetrics> |
valueOfUnscaled(S scaleMetrics,
long unscaled)
Creates and returns a new
GenericMutableDecimal with the scale
specified by the given scaleMetrics argument. |
createOrAssign, max, min, multiplyExact, scale, scale, scale, scale, set, set, set, set, set, set, set, set, set, set, set, set, setMinusOne, setOne, setUlp, setUnscaled, setUnscaled, setUnscaled, setZero, unscaledValue
abs, abs, add, add, add, add, add, add, add, add, addSquared, addSquared, addSquared, addUnscaled, addUnscaled, addUnscaled, addUnscaled, addUnscaled, avg, avg, byteValueExact, compareTo, compareToNumerically, divide, divide, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideBy, divideBy, divideBy, divideByPowerOfTen, divideByPowerOfTen, divideByPowerOfTen, divideExact, divideToIntegralValue, divideToIntegralValue, divideToLongValue, divideToLongValue, divideTruncate, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, doubleValue, doubleValue, equals, floatValue, floatValue, fractionalPart, getArithmeticFor, getArithmeticFor, getArithmeticFor, getCheckedArithmeticFor, getDefaultArithmetic, getDefaultCheckedArithmetic, getRoundingDownArithmetic, getRoundingFloorArithmetic, getRoundingHalfEvenArithmetic, getRoundingUnnecessaryArithmetic, hashCode, integralPart, intValue, intValueExact, invert, invert, invert, isBetweenZeroAndMinusOne, isBetweenZeroAndOne, isEqualTo, isEqualToNumerically, isGreaterThan, isGreaterThanOrEqualTo, isIntegral, isIntegralPartZero, isLessThan, isLessThanOrEqualTo, isMinusOne, isNegative, isNonNegative, isNonPositive, isOne, isPositive, isUlp, isZero, longValue, longValue, longValueExact, max, max, min, min, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyBy, multiplyBy, multiplyBy, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, negate, negate, pow, pow, pow, remainder, round, round, round, shiftLeft, shiftLeft, shiftLeft, shiftRight, shiftRight, shiftRight, shortValueExact, signum, sqrt, sqrt, square, square, square, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractSquared, subtractSquared, subtractSquared, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBigIntegerExact, toString
byteValue, shortValue
finalize, getClass, notify, notifyAll, wait, wait, wait
abs, abs, add, add, add, add, add, add, add, add, addSquared, addSquared, addSquared, addUnscaled, addUnscaled, addUnscaled, addUnscaled, addUnscaled, avg, avg, divide, divide, divide, divide, divide, divide, divide, divide, divideAndRemainder, divideAndRemainder, divideBy, divideBy, divideBy, divideByPowerOfTen, divideByPowerOfTen, divideByPowerOfTen, divideExact, divideToIntegralValue, divideToIntegralValue, divideTruncate, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, divideUnscaled, fractionalPart, integralPart, invert, invert, invert, multiply, multiply, multiply, multiply, multiply, multiply, multiply, multiplyBy, multiplyBy, multiplyBy, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyByPowerOfTen, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, multiplyUnscaled, negate, negate, pow, pow, pow, remainder, round, round, round, shiftLeft, shiftLeft, shiftLeft, shiftRight, shiftRight, shiftRight, sqrt, sqrt, square, square, square, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtract, subtractSquared, subtractSquared, subtractSquared, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled, subtractUnscaled
byteValue, byteValueExact, compareTo, compareToNumerically, divideToLongValue, divideToLongValue, doubleValue, doubleValue, equals, floatValue, floatValue, hashCode, intValue, intValueExact, isBetweenZeroAndMinusOne, isBetweenZeroAndOne, isEqualTo, isEqualToNumerically, isGreaterThan, isGreaterThanOrEqualTo, isIntegral, isIntegralPartZero, isLessThan, isLessThanOrEqualTo, isMinusOne, isNegative, isNonNegative, isNonPositive, isOne, isPositive, isUlp, isZero, longValue, longValue, longValueExact, max, min, shortValue, shortValueExact, signum, toBigDecimal, toBigDecimal, toBigInteger, toBigInteger, toBigIntegerExact, toString
public GenericMutableDecimal(S scaleMetrics)
GenericMutableDecimal
with value zero.scaleMetrics
- the metrics object defining the scale for the zero valuepublic GenericMutableDecimal(Decimal<S> decimal)
GenericMutableDecimal
with the same value and scale
as the given decimal
argument.decimal
- the numeric value to assign to the created mutable Decimalpublic GenericMutableDecimal(S scaleMetrics, long unscaledValue)
GenericMutableDecimal
with the scale specified by
the given scaleMetrics
argument. The numeric value of new the
Decimal is unscaledValue × 10-scale
scaleMetrics
- the metrics object defining the scale for the new valueunscaledValue
- the unscaled long value representing the new Decimal's
numerical value before applying the scale factorpublic static <S extends ScaleMetrics> GenericMutableDecimal<S> valueOf(Decimal<S> decimal)
GenericMutableDecimal
with the same
value and scale as the given decimal
argument.S
- the scale metrics typedecimal
- the numeric value to assign to the created mutable Decimaldecimal
argumentpublic static <S extends ScaleMetrics> GenericMutableDecimal<S> valueOfUnscaled(S scaleMetrics, long unscaled)
GenericMutableDecimal
with the scale
specified by the given scaleMetrics
argument. The numeric value
of new the Decimal is
unscaledValue × 10-scale
S
- the scale metrics typescaleMetrics
- the metrics object defining the scale for the new valueunscaled
- the unscaled long value representing the new Decimal's
numerical value before applying the scale factorunscaledValue × 10-scale
public static GenericMutableDecimal<?> valueOfUnscaled(int scale, long unscaled)
GenericMutableDecimal
with the
specified scale
and value. The numeric value of new the Decimal
is unscaledValue × 10-scale
scale
- the scale for the new valueunscaled
- the unscaled long value representing the new Decimal's
numerical value before applying the scale factorunscaledValue × 10-scale
protected GenericMutableDecimal<S> create(long unscaled)
AbstractDecimal
Decimal
whose value is
(unscaled × 10-scale).create
in class AbstractDecimal<S extends ScaleMetrics,GenericMutableDecimal<S extends ScaleMetrics>>
unscaled
- unscaled value to be returned as a Decimal
protected GenericMutableDecimal<S>[] createArray(int length)
AbstractDecimal
Decimal
array of the specified length
.createArray
in class AbstractDecimal<S extends ScaleMetrics,GenericMutableDecimal<S extends ScaleMetrics>>
length
- the length of the array to returnnew D[length]
protected GenericMutableDecimal<S> self()
AbstractDecimal
this
decimal value as concrete implementation subtype.self
in class AbstractDecimal<S extends ScaleMetrics,GenericMutableDecimal<S extends ScaleMetrics>>
this
public S getScaleMetrics()
Decimal
long
value underlying this Decimal
.getScaleMetrics
in interface Decimal<S extends ScaleMetrics>
ScaleMetrics.getScale()
,
ScaleMetrics.getScaleFactor()
public int getScale()
Decimal
long
value underlying this Decimal
.
If the scale is f
then the value represented by a Decimal
instance is
(unscaledValue × 10-f).
This method is a shortcut for getScaleMetrics().getScale()
.
getScale
in interface Decimal<S extends ScaleMetrics>
Decimal.getScaleMetrics()
,
ScaleMetrics.getScale()
,
Decimal.unscaledValue()
public GenericDecimalFactory<S> getFactory()
Decimal
this
Decimal.getFactory
in interface Decimal<S extends ScaleMetrics>
public GenericMutableDecimal<S> clone()
MutableDecimal
clone
in interface MutableDecimal<S extends ScaleMetrics>
clone
in class AbstractMutableDecimal<S extends ScaleMetrics,GenericMutableDecimal<S extends ScaleMetrics>>
public GenericImmutableDecimal<S> toImmutableDecimal()
Decimal
Decimal
value is already an ImmutableDecimal
it is simply returned. Otherwise a new
immutable value with the same scale and numerical value as this
Decimal is created and returned.toImmutableDecimal
in interface Decimal<S extends ScaleMetrics>
this
if immutable and a new ImmutableDecimal
with the same scale and value as
this
Decimal otherwisepublic GenericMutableDecimal<S> toMutableDecimal()
Decimal
Decimal
value is already a MutableDecimal
it is simply returned. Otherwise a new mutable
value with the same scale and numerical value as this
Decimal is created and returned.toMutableDecimal
in interface Decimal<S extends ScaleMetrics>
this
if mutable and a new MutableDecimal
with the same scale and value as this
Decimal otherwise