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, 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
byteValue, shortValue
clone, 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
public 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-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 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-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 GenericImmutableDecimal<?> valueOfUnscaled(int scale, long unscaled)
GenericImmutableDecimal
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
public S getScaleMetrics()
Decimal
long
value underlying this Decimal
.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()
.
Decimal.getScaleMetrics()
,
ScaleMetrics.getScale()
,
Decimal.unscaledValue()
public GenericDecimalFactory<S> getFactory()
Decimal
this
Decimal.protected GenericImmutableDecimal<S> self()
AbstractDecimal
this
decimal value as concrete implementation subtype.self
in class AbstractDecimal<S extends ScaleMetrics,GenericImmutableDecimal<S extends ScaleMetrics>>
this
protected GenericImmutableDecimal<S> createOrAssign(long unscaled)
AbstractDecimal
Decimal
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 Decimal
protected GenericImmutableDecimal<S> create(long unscaled)
AbstractDecimal
Decimal
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 Decimal
protected GenericImmutableDecimal<S>[] createArray(int length)
AbstractDecimal
Decimal
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()
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.this
if mutable and a new MutableDecimal
with the same scale and value as this
Decimal otherwisepublic 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.this
if immutable and a new ImmutableDecimal
with the same scale and value as
this
Decimal otherwise