public class DefaultNumberValue
extends javax.money.NumberValue
NumberValue based on BigDecimal.| Modifier and Type | Field and Description |
|---|---|
static javax.money.NumberValue |
ONE
The value 1, with a scale of 0.
|
| Constructor and Description |
|---|
DefaultNumberValue(java.lang.Number number) |
| Modifier and Type | Method and Description |
|---|---|
double |
doubleValue() |
double |
doubleValueExact()
Access the numeric value as
double. |
float |
floatValue() |
protected static java.math.BigDecimal |
getBigDecimal(java.lang.Number num)
Creates a
BigDecimal from the given Number doing the valid conversion
depending the type given. |
java.lang.Class<?> |
getNumberType()
Get the numeric implementation type, that is the base of this number.
|
int |
getPrecision()
Returns the precision of this
MonetaryAmount. |
int |
getScale()
Returns the scale of this
MonetaryAmount. |
int |
intValue() |
int |
intValueExact()
Access the numeric value as
int. |
long |
longValue() |
long |
longValueExact()
Access the numeric value as
long. |
<T extends java.lang.Number> |
numberValue(java.lang.Class<T> numberType)
Access the numeric value as
Number. |
<T extends java.lang.Number> |
numberValueExact(java.lang.Class<T> numberType)
Access the numeric value as
Number. |
static javax.money.NumberValue |
of(java.lang.Number number)
Creates a new instance of
NumberValue, using the given number. |
java.lang.String |
toString() |
public static final javax.money.NumberValue ONE
BigDecimal.ONEpublic double doubleValue()
doubleValue in class java.lang.Numberpublic double doubleValueExact()
javax.money.NumberValuedouble. Hereby no truncation will be performed to fit the
value into the target data type.doubleValueExact in class javax.money.NumberValueMonetaryAmount.public float floatValue()
floatValue in class java.lang.Numberprotected static java.math.BigDecimal getBigDecimal(java.lang.Number num)
BigDecimal from the given Number doing the valid conversion
depending the type given.num - the number typeBigDecimalpublic java.lang.Class<?> getNumberType()
javax.money.NumberValuegetNumberType in class javax.money.NumberValuenull.public int getPrecision()
javax.money.NumberValueMonetaryAmount. (The precision is the number of
digits in the unscaled value.)
The precision of a zero value is 1.getPrecision in class javax.money.NumberValueMonetaryAmount.public int getScale()
javax.money.NumberValueMonetaryAmount. 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.getScale in class javax.money.NumberValueMonetaryAmount.public int intValue()
intValue in class java.lang.Numberpublic int intValueExact()
javax.money.NumberValueint. Hereby no truncation will be performed to fit the
value into the target data type.intValueExact in class javax.money.NumberValueMonetaryAmount.public long longValue()
longValue in class java.lang.Numberpublic long longValueExact()
javax.money.NumberValuelong. Hereby no truncation will be performed to fit the
value into the target data type.longValueExact in class javax.money.NumberValueMonetaryAmount.public <T extends java.lang.Number> T numberValue(java.lang.Class<T> numberType)
javax.money.NumberValueNumber. Hereby truncation may be performed as needed to
fit the value into the target data type.numberValue in class javax.money.NumberValuenumberType - The concrete number class to be returned. Basically the following Number types,
must be supported if available on the corresponding runtime platform:
java.lang.Longjava.lang.Doublejava.lang.Numberjava.math.BigInteger, currently not available on all platforms.java.math.BigDecimal, currently not available on all platforms.MonetaryAmount.public <T extends java.lang.Number> T numberValueExact(java.lang.Class<T> numberType)
javax.money.NumberValueNumber. Hereby no truncation will be performed to fit the
value into the target data type.numberValueExact in class javax.money.NumberValuenumberType - The concrete number class to be returned. Basically the following Number types,
must be supported if available on the corresponding runtime platform:
java.lang.Longjava.lang.Doublejava.lang.Numberjava.math.BigInteger, currently not available on all platforms.java.math.BigDecimal, currently not available on all platforms.MonetaryAmount.public static javax.money.NumberValue of(java.lang.Number number)
NumberValue, using the given number.number - The numeric part, not null.NumberValue.public java.lang.String toString()
toString in class java.lang.Object