|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@ComponentSpecification public interface MathUtil
This is the interface for a collection of utility functions to deal with
Numbers.
| Method Summary | ||
|---|---|---|
NumberType<? extends Number> |
getNumberType(Class<?> numericType)
This method gets the NumberType for the given
numericType. |
|
|
getNumberTypeGeneric(Class<NUMBER> numericType)
This method gets the NumberType for the given
numericType. |
|
Number |
toSimplestNumber(Number value)
This method converts the given value to the simplest suitable number-type. |
|
| Method Detail |
|---|
NumberType<? extends Number> getNumberType(Class<?> numericType)
NumberType for the given
numericType.
numericType - is the class reflecting a Number. It may be
primitive (such as
int.class). The signature is NOT bound to
Number to make it easy for the caller (e.g.
Number.class.isAssignableFrom(int.class) is
false).
NumberType representing the given
numericType or null if the given
numericType is no Number or is NOT known (you
may extend this MathUtil in such case).getNumberTypeGeneric(Class)<NUMBER extends Number> NumberType<NUMBER> getNumberTypeGeneric(Class<NUMBER> numericType)
NumberType for the given
numericType.
NUMBER - is the generic type of the numericType.numericType - is the class reflecting a Number. It may be
primitive (such as
int.class).
NumberType representing the given
numericType or null if the given
numericType is NOT known (you may extend this
MathUtil in such case).Number toSimplestNumber(Number value)
number-type. The ordering implied by "simplest" is
Byte < Short < Integer < Long <
Float < Double.Double is only converted to
Float if the result is exactly the same. Be aware that
0.2F - 0.2 is NOT 0.0 (but
2.980232227667301E-9).
value - is the value to convert.
Number.doubleValue() as the given
value and the simplest possible type.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||