public class ClassHandler extends Object
Utility class to create new class objects.
Uses Reflection Java API.
| Modifier and Type | Class and Description |
|---|---|
static class |
ClassHandler.BooleanStringConverter |
static class |
ClassHandler.ColorStringConverter |
static class |
ClassHandler.DefaultStringConverter |
static interface |
ClassHandler.StringConverter |
| Modifier and Type | Field and Description |
|---|---|
protected static Map |
PRIMITIVE_CLASS_OBJECT |
protected static Map |
PRIMITIVE_CLASS_TYPE |
protected static Map |
STRING_CONVERTERS |
| Constructor and Description |
|---|
ClassHandler() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
getClassInstance(String className)
Returns the
Object instance for the given className |
static Class |
getClassObject(String className)
Returns the
Class object for the given className. |
static Class |
getClassObject(String className,
boolean primitiveTypes)
Returns the
Class object for the given className. |
static Method |
getMethodObject(Object source,
String name)
|
static Method |
getMethodObject(Object source,
String name,
Class[] clazz)
|
static Object |
getValueObject(String className,
String value)
|
protected static final Map PRIMITIVE_CLASS_TYPE
protected static final Map PRIMITIVE_CLASS_OBJECT
protected static Map STRING_CONVERTERS
public static Class getClassObject(String className) throws IllegalArgumentException
Returns the Class object for the given className.
className - The class name of the Class object.Class object for the given className.IllegalArgumentExceptionpublic static Class getClassObject(String className, boolean primitiveTypes) throws IllegalArgumentException
Returns the Class object for the given className.
Allows to return Class objects for the Java primitive types.
className - The class name of the Class object.primitiveTypes - If true, return the Class for Java primitive types.Class object for the given className.IllegalArgumentExceptionpublic static Object getClassInstance(String className) throws IllegalArgumentException
Returns the Object instance for the given className
className - The class name of the Class object.Object instance for the given classNameIllegalArgumentExceptionpublic static Method getMethodObject(Object source, String name)
Returns the Method of the given Object source with
the given name.
source - Object with the method.name - of the method to return.Method with the given namepublic static Method getMethodObject(Object source, String name, Class[] clazz)
Returns the Method of the given Object source with
the name and the parameter class.
public static Object getValueObject(String className, String value) throws IllegalArgumentException
Returns the given String value converted into the
className Class.
Some classes have a custom converter, else the default converter uses the
contructor class with the String parameter (a
IllegalArgumentException can be thrown).
className - The class name of the returned object value.value - The String to convert.IllegalArgumentExceptionCopyright © 2016 Imatia Innovation S.L.. All rights reserved.