|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.math.base.MathUtilImpl
@Singleton @Named public class MathUtilImpl
This class is a collection of utility functions for dealing with numbers.
| Field Summary | |
|---|---|
private static MathUtil |
instance
|
| Constructor Summary | |
|---|---|
MathUtilImpl()
The constructor. |
|
| Method Summary | ||
|---|---|---|
static MathUtil |
getInstance()
This method gets the singleton instance of MathUtil. |
|
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. |
|
| Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
|---|
doInitialize, getLogger, setLogger |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent |
|---|
doInitialized, getInitializationState, initialize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static MathUtil instance
getInstance()| Constructor Detail |
|---|
public MathUtilImpl()
| Method Detail |
|---|
public static MathUtil getInstance()
MathUtil.getInstance() methods and
construct new instances via the container-framework of your choice (like
plexus, pico, springframework, etc.). To wire up the dependent components
everything is properly annotated using common-annotations (JSR-250). If
your container does NOT support this, you should consider using a better
one.
public NumberType<? extends Number> getNumberType(Class<?> numericType)
NumberType for the given
numericType.
getNumberType in interface MathUtilnumericType - 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).MathUtil.getNumberTypeGeneric(Class)public <NUMBER extends Number> NumberType<NUMBER> getNumberTypeGeneric(Class<NUMBER> numericType)
NumberType for the given
numericType.
getNumberTypeGeneric in interface MathUtilNUMBER - 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).public 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).
toSimplestNumber in interface MathUtilvalue - 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 | |||||||||