S - the scale metrics type associated with
decimals created by this factorypublic interface DecimalFactory<S extends ScaleMetrics>
| Modifier and Type | Method and Description |
|---|---|
DecimalFactory<?> |
deriveFactory(int scale)
Returns a factory for the given
scale. |
<S extends ScaleMetrics> |
deriveFactory(S scaleMetrics)
Returns a factory for the given
scaleMetrics. |
int |
getScale()
Returns the scale of values created by this factory.
|
S |
getScaleMetrics()
Returns the scale metrics type associated with Decimal values created by
this factory.
|
Class<? extends ImmutableDecimal<S>> |
immutableType()
Returns the implementing class for immutable values.
|
Class<? extends MutableDecimal<S>> |
mutableType()
Returns the implementing class for mutable values.
|
ImmutableDecimal<S>[] |
newArray(int length)
Creates a one dimensional array of the specified
length for
immutable Decimal values. |
MutableDecimal<S> |
newMutable()
Creates a new mutable value initialized with zero.
|
MutableDecimal<S>[] |
newMutableArray(int length)
Creates a one dimensional array of the specified
length for
mutable Decimal values. |
ImmutableDecimal<S> |
parse(String value)
Translates the string representation of a
Decimal into an
immutable Decimal. |
ImmutableDecimal<S> |
parse(String value,
RoundingMode roundingMode)
Translates the string representation of a
Decimal into an
immutable Decimal. |
ImmutableDecimal<S> |
valueOf(BigDecimal value)
Returns a new immutable Decimal whose value is calculated by rounding the
specified
BigDecimal argument to the scale of
this factory using HALF_UP rounding. |
ImmutableDecimal<S> |
valueOf(BigDecimal value,
RoundingMode roundingMode)
Returns a new immutable Decimal whose value is calculated by rounding the
specified
BigDecimal argument to the scale of
this factory using the specified roundingMode. |
ImmutableDecimal<S> |
valueOf(BigInteger value)
Returns a new immutable Decimal whose value is numerically equal to that
of the specified
BigInteger value. |
ImmutableDecimal<S> |
valueOf(Decimal<?> value)
|
ImmutableDecimal<S> |
valueOf(Decimal<?> value,
RoundingMode roundingMode)
|
ImmutableDecimal<S> |
valueOf(double value)
|
ImmutableDecimal<S> |
valueOf(double value,
RoundingMode roundingMode)
Returns a new immutable Decimal whose value is calculated by rounding the
specified
double argument to the scale of
this factory using the specified roundingMode. |
ImmutableDecimal<S> |
valueOf(float value)
|
ImmutableDecimal<S> |
valueOf(float value,
RoundingMode roundingMode)
Returns a new immutable Decimal whose value is calculated by rounding the
specified
float argument to the scale of this
factory using the specified roundingMode. |
ImmutableDecimal<S> |
valueOf(long value)
Returns a new immutable Decimal whose value is numerically equal to that
of the specified
long value. |
ImmutableDecimal<S> |
valueOfUnscaled(long unscaled)
Returns a new immutable Decimal whose value is numerically equal to
(unscaled × 10-scale) where
scale
refers to this factory's scale. |
ImmutableDecimal<S> |
valueOfUnscaled(long unscaled,
int scale)
Returns a new immutable Decimal whose value is numerically equal to
(unscaled × 10-scale).
|
ImmutableDecimal<S> |
valueOfUnscaled(long unscaled,
int scale,
RoundingMode roundingMode)
Returns a new immutable Decimal whose value is numerically equal to
(unscaled × 10-scale).
|
S getScaleMetrics()
int getScale()
Class<? extends ImmutableDecimal<S>> immutableType()
Class<? extends MutableDecimal<S>> mutableType()
DecimalFactory<?> deriveFactory(int scale)
scale.scale - the scale of Decimal numbers created by the returned factory<S extends ScaleMetrics> DecimalFactory<S> deriveFactory(S scaleMetrics)
scaleMetrics.S - the generic type for scaleMetricsscaleMetrics - the metrics defining the scale of the Decimal numbers created
by the returned factoryscaleMetricsImmutableDecimal<S> valueOf(long value)
long value. An exception is thrown if the
specified value is too large to be represented as a Decimal of this
factory's scale.value - long value to convert into an immutable Decimal valuelong
valueIllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this factoryImmutableDecimal<S> valueOf(float value)
float argument to the scale of this
factory using HALF_UP rounding. An exception
is thrown if the specified value is too large to be represented as a
Decimal of this factory's scale.value - float value to convert into an immutable Decimal valueIllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the float to be represented as a
Decimal with the scale of this factoryImmutableDecimal<S> valueOf(float value, RoundingMode roundingMode)
float argument to the scale of this
factory using the specified roundingMode. An exception is thrown
if the specified value is too large to be represented as a Decimal of
this factory's scale.value - float value to convert into an immutable Decimal valueroundingMode - the rounding mode to apply during the conversion if necessaryIllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the float to be represented as a
Decimal with the scale of this factoryArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S> valueOf(double value)
double argument to the scale of
this factory using HALF_UP rounding. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this factory's scale.value - double value to convert into an immutable Decimal valueIllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the double to be represented as a
Decimal with the scale of this factoryImmutableDecimal<S> valueOf(double value, RoundingMode roundingMode)
double argument to the scale of
this factory using the specified roundingMode. An exception is
thrown if the specified value is too large to be represented as a Decimal
of this factory's scale.value - double value to convert into an immutable Decimal valueroundingMode - the rounding mode to apply during the conversion if necessaryIllegalArgumentException - if value is NaN or infinite or if the magnitude is
too large for the double to be represented as a
Decimal with the scale of this factoryArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S> valueOf(BigInteger value)
BigInteger value. An exception is thrown if the
specified value is too large to be represented as a Decimal of this
factory's scale.value - BigInteger value to convert into an immutable Decimal
valueIllegalArgumentException - if value is too large to be represented as a Decimal
with the scale of this factoryImmutableDecimal<S> valueOf(BigDecimal value)
BigDecimal argument to the scale of
this factory using HALF_UP rounding. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this factory's scale.value - BigDecimal value to convert into an immutable Decimal
valueIllegalArgumentException - if value too large to be represented as a Decimal
with the scale of this factoryImmutableDecimal<S> valueOf(BigDecimal value, RoundingMode roundingMode)
BigDecimal argument to the scale of
this factory using the specified roundingMode. An exception is
thrown if the specified value is too large to be represented as a Decimal
of this factory's scale.value - BigDecimal value to convert into an immutable Decimal
valueroundingMode - the rounding mode to apply during the conversion if necessaryIllegalArgumentException - if value too large to be represented as a Decimal
with the scale of this factoryArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S> valueOf(Decimal<?> value)
Decimal argument to the scale of
this factory using HALF_UP rounding. An
exception is thrown if the specified value is too large to be represented
as a Decimal of this factory's scale.value - Decimal value to convert into an immutable Decimal value of
this factory's scaleIllegalArgumentException - if value too large to be represented as a Decimal
with the scale of this factoryImmutableDecimal<S> valueOf(Decimal<?> value, RoundingMode roundingMode)
Decimal argument to the scale of
this factory using the specified roundingMode. An exception is
thrown if the specified value is too large to be represented as a Decimal
of this factory's scale.value - Decimal value to convert into an immutable Decimal value of
this factory's scaleroundingMode - the rounding mode to apply during the conversion if necessaryIllegalArgumentException - if value too large to be represented as a Decimal
with the scale of this factoryArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S> parse(String value)
Decimal into an
immutable Decimal. The string representation consists of an
optional sign, '+' or '-' , followed by a sequence of
zero or more decimal digits ("the integer"), optionally followed by a
fraction.
The fraction consists of a decimal point followed by zero or more decimal
digits. The string must contain at least one digit in either the integer
or the fraction. If the fraction contains more digits than this factory's
scale, the value is rounded using
HALF_UP rounding. An exception is thrown if
the value is too large to be represented as a Decimal of this factory's
scale.
value - String value to convert into an immutable Decimal value of
this factory's scaleNumberFormatException - if value does not represent a valid Decimal
or if the value is too large to be represented as a Decimal
with the scale of this factoryImmutableDecimal<S> parse(String value, RoundingMode roundingMode)
Decimal into an
immutable Decimal. The string representation consists of an
optional sign, '+' or '-' , followed by a sequence of
zero or more decimal digits ("the integer"), optionally followed by a
fraction.
The fraction consists of a decimal point followed by zero or more decimal
digits. The string must contain at least one digit in either the integer
or the fraction. If the fraction contains more digits than this factory's
scale, the value is rounded using the specified
roundingMode. An exception is thrown if the value is too large to
be represented as a Decimal of this factory's scale.
value - String value to convert into an immutable Decimal value of
this factory's scaleroundingMode - the rounding mode to apply if the fraction contains more
digits than the scale of this factoryNumberFormatException - if value does not represent a valid Decimal
or if the value is too large to be represented as a Decimal
with the scale of this factoryArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S> valueOfUnscaled(long unscaled)
scale
refers to this factory's scale.unscaled - unscaled value to convert into an immutable Decimal valueImmutableDecimal<S> valueOfUnscaled(long unscaled, int scale)
scale of this factory using
HALF_UP rounding. An exception is thrown if
the specified value is too large to be represented as a Decimal of this
factory's scale.unscaled - unscaled value to convert into an immutable Decimal valuescale - the scale to apply to the unscaled valueIllegalArgumentException - if value too large to be represented as a Decimal of
this factory's scaleImmutableDecimal<S> valueOfUnscaled(long unscaled, int scale, RoundingMode roundingMode)
scale of this factory using the specified
roundingMode. An exception is thrown if the specified value is
too large to be represented as a Decimal of this factory's scale.unscaled - unscaled value to convert into an immutable Decimal valuescale - the scale to apply to the unscaled valueroundingMode - the rounding mode to apply during the conversion if necessaryIllegalArgumentException - if value too large to be represented as a Decimal of
this factory's scaleArithmeticException - if roundingMode==UNNECESSARY and rounding is
necessaryImmutableDecimal<S>[] newArray(int length)
length for
immutable Decimal values.length - the length of the returned arrayMutableDecimal<S> newMutable()
MutableDecimal<S>[] newMutableArray(int length)
length for
mutable Decimal values.length - the length of the returned array