NUMBER - is the generic type of the represented number-class.public abstract class NumberTypeImpl<NUMBER extends Number> extends Object implements NumberType<NUMBER>
NumberType interface.MathUtilImpl.getNumberType(Class)| Modifier and Type | Field and Description |
|---|---|
static NumberTypeImpl<BigDecimal> |
BIG_DECIMAL
The
NumberTypeImpl for BigDecimal. |
static NumberTypeImpl<BigInteger> |
BIG_INTEGER
The
NumberTypeImpl for BigInteger. |
static NumberTypeImpl<Byte> |
BYTE
The
NumberTypeImpl for Byte. |
static NumberTypeImpl<Double> |
DOUBLE
The
NumberTypeImpl for Double. |
private int |
exactness |
static NumberTypeImpl<Float> |
FLOAT
The
NumberTypeImpl for Float. |
static NumberTypeImpl<Integer> |
INTEGER
The
NumberTypeImpl for Integer. |
static NumberTypeImpl<Long> |
LONG
The
NumberTypeImpl for Long. |
private NUMBER |
maximumValue |
private NUMBER |
minimumValue |
private static double |
REQUIRED_PRECISION
The maximum delta allowed for
valueOf(Number, boolean). |
static NumberTypeImpl<Short> |
SHORT
The
NumberTypeImpl for Short. |
| Constructor and Description |
|---|
NumberTypeImpl(int exactness,
NUMBER min,
NUMBER max)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract NUMBER |
convert(Number number)
This method converts the given
number to the number-class represented by
this object. |
int |
getExactnessDifference(NumberType<?> otherType)
This method gets the difference of the exactness of this
NumberTypeImpl and the given
otherType. |
NUMBER |
getMaximumValue()
This method gets the maximum
value of this object. |
NUMBER |
getMinimumValue()
This method gets the minimum
value of this object. |
protected abstract NUMBER |
parse(String number)
This method gets an instance of the
represented number-class with the numeric value
identified by the given string number. |
NUMBER |
valueOf(Number number,
boolean failIfUnprecise)
This method gets an instance of the
represented number-class with the numeric value given
by number. |
NUMBER |
valueOf(String number)
This method gets an instance of the
represented number-class with the numeric value
identified by the given string number. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetNumberClass, isDecimalprivate static final double REQUIRED_PRECISION
valueOf(Number, boolean).public static final NumberTypeImpl<Byte> BYTE
NumberTypeImpl for Byte.public static final NumberTypeImpl<Short> SHORT
NumberTypeImpl for Short.public static final NumberTypeImpl<Integer> INTEGER
NumberTypeImpl for Integer.public static final NumberTypeImpl<Long> LONG
NumberTypeImpl for Long.public static final NumberTypeImpl<Float> FLOAT
NumberTypeImpl for Float.public static final NumberTypeImpl<Double> DOUBLE
NumberTypeImpl for Double.public static final NumberTypeImpl<BigInteger> BIG_INTEGER
NumberTypeImpl for BigInteger.public static final NumberTypeImpl<BigDecimal> BIG_DECIMAL
NumberTypeImpl for BigDecimal.private final int exactness
getExactnessDifference(NumberType)private final NUMBER extends Number minimumValue
getMinimumValue()private final NUMBER extends Number maximumValue
getMaximumValue()NumberTypeImpl(int exactness,
NUMBER min,
NUMBER max)
exactness - is the internal exactness level for getExactnessDifference(NumberType).min - is the minimum value.max - is the maximum value.protected abstract NUMBER convert(Number number)
number to the number-class represented by
this object. Like a cast this operation may loose precision (e.g. when converting a Double to
Integer) without warning. Use valueOf(Number, boolean) instead to avoid this.number - is the number to convert.public NUMBER valueOf(Number number, boolean failIfUnprecise) throws NumberConversionException
represented number-class with the numeric value given
by number.valueOf in interface NumberType<NUMBER extends Number>number - is the numeric value to convert.failIfUnprecise - - if true and conversion causes precision loss, a
NumberConversionException is thrown, if false this method acts like a primitive cast
and conversion is always successfully.Number instance of the represented number-class with the value of the
given number. This will be the same instance as number if it is an
instance of the represented number-class .NumberConversionException - if the conversion will loose precision (e.g. when converting a decimal
Double to Integer)public NUMBER valueOf(String number) throws NumberConversionException
represented number-class with the numeric value
identified by the given string number.valueOf in interface NumberType<NUMBER extends Number>number - is the string to be parsed as number.NumberConversionException - if the given number has an illegal format.protected abstract NUMBER parse(String number) throws NumberConversionException, NumberFormatException
represented number-class with the numeric value
identified by the given string number.number - is the string to be parsed as number.NumberConversionException - if the given number has an illegal format.NumberFormatException - if the given number has an illegal format. This exception will be
converted to a NumberConversionException.public int getExactnessDifference(NumberType<?> otherType)
NumberTypeImpl and the given
otherType. Double and BigInteger are NOT really comparable so the exactness difference
might only make sense if the compared types are both decimal or both
non-decimal (mathematical integers). However the order of typical types is:getExactnessDifference in interface NumberType<NUMBER extends Number>otherType - is the NumberTypeImpl to compare with.0 if this NumberTypeImpl is equal to
otherType, positive if this NumberTypeImpl is more exact (later in the examples above)
and negative if otherType is more exact.public NUMBER getMinimumValue()
value of this object. A legal value has
to be greater or equal to this minimum.
Will return null in case of an unbounded type such as BigInteger.getMinimumValue in interface AttributeReadMinimumValue<NUMBER extends Number>getMinimumValue in interface NumberType<NUMBER extends Number>value or
null if unbounded.public NUMBER getMaximumValue()
value of this object. A legal value has
to be less or equal to this maximum.
Will return null in case of an unbounded type such as BigInteger.getMaximumValue in interface AttributeReadMaximumValue<NUMBER extends Number>getMaximumValue in interface NumberType<NUMBER extends Number>value or
null if unbounded.Copyright © 2001–2015 mmm-Team. All rights reserved.