public final class TypeHandling extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
cast(Object o,
Class<T> type)
Check if an object is of a specified type and cast it to that if possible.
|
static Class<?> |
getClassWithName(String name)
Return the class object for given type name.
|
static String |
getNumericString(Number value)
Check for missing values, and return the numeric value in string format
JMC-6256: JMC doesn't respect Long.MIN_VALUE as a missing value
As per the bug report, the following values should be considered "missing"
- Integer.MIN_VALUE
- Long.MIN_VALUE
- Double.NaN
- Double.NEGATIVE_INFINITY
- Float.NaN
- Float.NEGATIVE_INFINITY
|
static String |
getValueString(Object value)
Returns the value in possible augmented way.
|
static String |
getVerboseString(Object value)
Returns a possibly more verbose description of an object.
|
static boolean |
isPrimitive(String className)
Check if a class name represents a primitive type or not.
|
static String |
simplifyType(String typeName)
Returns a simplified description of a type name.
|
static Class<?> |
toNonPrimitiveClass(Class<?> primitiveClass)
Return the non-primitive class corresponding to argument class (int -> Integer).
|
public static String simplifyType(String typeName)
typeName
- a type namepublic static String getValueString(Object value)
value
- the value to textualizepublic static String getVerboseString(Object value)
getValueString(Object)
, but can return longer texts.value
- the value to textualizepublic static String getNumericString(Number value)
value
- the numeric value to be converted to a stringpublic static Class<?> getClassWithName(String name) throws ClassNotFoundException
name
- the name of the typeClassNotFoundException
- if name is an invalid class namepublic static Class<?> toNonPrimitiveClass(Class<?> primitiveClass)
primitiveClass
- the class to convertpublic static boolean isPrimitive(String className)
className
- the name to checktrue
if the class name represents a primitive type, false
otherwiseCopyright © 2020. All rights reserved.