NUMBER
- is the generic type of the represented number-class
.public interface NumberType<NUMBER extends Number> extends AttributeReadMinimumValue<NUMBER>, AttributeReadMaximumValue<NUMBER>
type
reflecting a specific Number
. It allows to check attributes like
isDecimal()
or to compare
NumberType
s. from string
or
by converting an given number
. Enum
to be extensible.MathUtilImpl.getNumberType(Class)
Modifier and Type | Method and Description |
---|---|
int |
getExactnessDifference(NumberType<?> otherType)
This method gets the difference of the exactness of this
NumberType 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. |
Class<NUMBER> |
getNumberClass()
|
boolean |
isDecimal()
This method determines if the represented
Number is a decimal value. |
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 . |
NUMBER valueOf(Number number, boolean failIfUnprecise) throws NumberConversionException
represented number-class
with the numeric value given
by 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
)NUMBER valueOf(String number) throws NumberConversionException
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.boolean isDecimal()
Number
is a decimal value. Double
, Float
, or BigDecimal
represent decimal values while Integer
or Long
are NOT decimal.true
if the represented Number
is a decimal value.int getExactnessDifference(NumberType<?> otherType)
NumberType
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:otherType
- is the NumberType
to compare with.0
if this NumberType
is equal to
otherType
, positive if this NumberType
is more exact (later in the examples above) and
negative if otherType
is more exact.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>
value
or
null
if unbounded.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>
value
or
null
if unbounded.Copyright © 2001–2014 mmm-Team. All rights reserved.