S - the scale metrics type associated with this decimalpublic final class GenericImmutableDecimal<S extends ScaleMetrics> extends AbstractImmutableDecimal<S,GenericImmutableDecimal<S>>
ImmutableDecimal implemented
in a generic way, that is, different instances can have different scales. In
contrast the classes defined in the immutable package have have no
generic parameter as they have a fixed scale per class.| Constructor and Description |
|---|
GenericImmutableDecimal(Decimal<S> decimal)
Creates a new
GenericImmutableDecimal with the same value and scale
as the given decimal argument. |
GenericImmutableDecimal(S scaleMetrics,
long unscaledValue)
Creates a new
GenericImmutableDecimal with the scale specified by
the given scaleMetrics argument. |
| Modifier and Type | Method and Description |
|---|---|
protected GenericImmutableDecimal<S> |
create(long unscaled)
Returns a new
Decimal whose value is
(unscaled × 10-scale). |
protected GenericImmutableDecimal<S>[] |
createArray(int length)
Returns a new
Decimal array of the specified length. |
protected GenericImmutableDecimal<S> |
createOrAssign(long unscaled)
Returns this or a new
Decimal whose value is
(unscaled × 10-scale). |
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 GenericImmutableDecimal<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
GenericImmutableDecimal with the same
value and scale as the given decimal argument. |
static GenericImmutableDecimal<?> |
valueOfUnscaled(int scale,
long unscaled)
Creates and returns a new
GenericImmutableDecimal with the
specified scale and value. |
static <S extends ScaleMetrics> |
valueOfUnscaled(S scaleMetrics,
long unscaled)
Creates and returns a new
GenericImmutableDecimal with the scale
specified by the given scaleMetrics argument. |
max, min, multiplyExact, scale, scale, scale, scale, toString, unscaledValueabs, 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, toBigIntegerExactbyteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitabs, 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, subtractUnscaledbyteValue, 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, toBigIntegerExactpublic GenericImmutableDecimal(S scaleMetrics, long unscaledValue)
GenericImmutableDecimal with the scale specified by
the given scaleMetrics argument. The numeric value of new the
Decimal is unscaledValue × 10-scalescaleMetrics - 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 GenericImmutableDecimal(Decimal<S> decimal)
GenericImmutableDecimal with the same value and scale
as the given decimal argument.decimal - the numeric value to assign to the created immutable Decimalpublic static <S extends ScaleMetrics> GenericImmutableDecimal<S> valueOf(Decimal<S> decimal)
GenericImmutableDecimal with the same
value and scale as the given decimal argument.S - the scale metrics typedecimal - the numeric value to assign to the created immutable Decimaldecimal argumentpublic static <S extends ScaleMetrics> GenericImmutableDecimal<S> valueOfUnscaled(S scaleMetrics, long unscaled)
GenericImmutableDecimal with the scale
specified by the given scaleMetrics argument. The numeric value
of new the Decimal is
unscaledValue × 10-scaleS - 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-scalepublic static GenericImmutableDecimal<?> valueOfUnscaled(int scale, long unscaled)
GenericImmutableDecimal with the
specified scale and value. The numeric value of new the Decimal
is unscaledValue × 10-scalescale - the scale for the new valueunscaled - the unscaled long value representing the new Decimal's
numerical value before applying the scale factorunscaledValue × 10-scalepublic S getScaleMetrics()
Decimallong value underlying this Decimal.ScaleMetrics.getScale(),
ScaleMetrics.getScaleFactor()public int getScale()
Decimallong 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().
Decimal.getScaleMetrics(),
ScaleMetrics.getScale(),
Decimal.unscaledValue()public GenericDecimalFactory<S> getFactory()
Decimalthis Decimal.protected GenericImmutableDecimal<S> self()
AbstractDecimalthis decimal value as concrete implementation subtype.self in class AbstractDecimal<S extends ScaleMetrics,GenericImmutableDecimal<S extends ScaleMetrics>>thisprotected GenericImmutableDecimal<S> createOrAssign(long unscaled)
AbstractDecimalDecimal whose value is
(unscaled × 10-scale).
The returned value is a new instance if this decimal is an
ImmutableDecimal. If it is a MutableDecimal then its
internal state is altered and this is returned as result now
representing (unscaled × 10-scale).
createOrAssign in class AbstractDecimal<S extends ScaleMetrics,GenericImmutableDecimal<S extends ScaleMetrics>>unscaled - unscaled value to be returned as a Decimalprotected GenericImmutableDecimal<S> create(long unscaled)
AbstractDecimalDecimal whose value is
(unscaled × 10-scale).create in class AbstractDecimal<S extends ScaleMetrics,GenericImmutableDecimal<S extends ScaleMetrics>>unscaled - unscaled value to be returned as a Decimalprotected GenericImmutableDecimal<S>[] createArray(int length)
AbstractDecimalDecimal array of the specified length.createArray in class AbstractDecimal<S extends ScaleMetrics,GenericImmutableDecimal<S extends ScaleMetrics>>length - the length of the array to returnnew D[length]public GenericMutableDecimal<S> toMutableDecimal()
DecimalDecimal 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.this if mutable and a new MutableDecimal with the same scale and value as this
Decimal otherwisepublic GenericImmutableDecimal<S> toImmutableDecimal()
DecimalDecimal 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.this if immutable and a new ImmutableDecimal with the same scale and value as
this Decimal otherwise