public abstract class NumberValue
extends java.lang.Number
MonetaryAmount
. The classs extends
Number
for maximal compatibility with the JDK but
also adds additional functionalities to overcome some of the pitfalls of the JDK's Number class.
Implementations of this interface must be
Constructor and Description |
---|
NumberValue() |
Modifier and Type | Method and Description |
---|---|
abstract double |
doubleValueExact()
Access the numeric value as
double . |
abstract java.lang.Class<?> |
getNumberType()
Get the numeric implementation type, that is the base of this number.
|
abstract int |
getPrecision()
Returns the precision of this
MonetaryAmount . |
abstract int |
getScale()
Returns the scale of this
MonetaryAmount . |
abstract int |
intValueExact()
Access the numeric value as
int . |
abstract long |
longValueExact()
Access the numeric value as
long . |
abstract <T extends java.lang.Number> |
numberValue(java.lang.Class<T> numberType)
Access the numeric value as
Number . |
abstract <T extends java.lang.Number> |
numberValueExact(java.lang.Class<T> numberType)
Access the numeric value as
Number . |
public abstract double doubleValueExact()
double
. Hereby no truncation will be performed to fit the
value into the target data type.MonetaryAmount
.java.lang.ArithmeticException
- If the value must be truncated to fit the target datatype.public abstract java.lang.Class<?> getNumberType()
null
.public abstract int getPrecision()
MonetaryAmount
. (The precision is the number of
digits in the unscaled value.)
The precision of a zero value is 1.MonetaryAmount
.public abstract int getScale()
MonetaryAmount
. If zero or positive, the scale is
the number of digits to the right of the decimal point. If negative, the unscaled value of
the number is multiplied by ten to the power of the negation of the scale. For example, a
scale of -3
means the unscaled value is multiplied by 1000.MonetaryAmount
.public abstract int intValueExact()
int
. Hereby no truncation will be performed to fit the
value into the target data type.MonetaryAmount
.java.lang.ArithmeticException
- If the value must be truncated to fit the target datatype.public abstract long longValueExact()
long
. Hereby no truncation will be performed to fit the
value into the target data type.MonetaryAmount
.java.lang.ArithmeticException
- If the value must be truncated to fit the target datatype.public abstract <T extends java.lang.Number> T numberValue(java.lang.Class<T> numberType)
Number
. Hereby truncation may be performed as needed to
fit the value into the target data type.numberType
- The concrete number class to be returned. Basically the following Number types,
must be supported if available on the corresponding runtime platform:
java.lang.Long
java.lang.Double
java.lang.Number
java.math.BigInteger
, currently not available on all platforms.java.math.BigDecimal
, currently not available on all platforms.MonetaryAmount
.public abstract <T extends java.lang.Number> T numberValueExact(java.lang.Class<T> numberType)
Number
. Hereby no truncation will be performed to fit the
value into the target data type.numberType
- The concrete number class to be returned. Basically the following Number types,
must be supported if available on the corresponding runtime platform:
java.lang.Long
java.lang.Double
java.lang.Number
java.math.BigInteger
, currently not available on all platforms.java.math.BigDecimal
, currently not available on all platforms.MonetaryAmount
.java.lang.ArithmeticException
- If the value must be truncated to fit the target datatype.