public class TypeUtility extends Object
Constructor and Description |
---|
TypeUtility() |
Modifier and Type | Method and Description |
---|---|
protected static String |
fromGetter(Method aMethod) |
static boolean |
isGetter(Method aMethod)
Tests whether we have a getter method.
|
static boolean |
isSetter(Method aMethod)
Tests whether we have a setter method.
|
static String |
toPropertyName(Field aField)
Converts a field's name to a property name.
|
static String |
toPropertyName(Method aMethod)
Converts a method's name to a property name.
|
static <T> T |
toType(Object aValue,
Class<T> aType)
Creates an instance of the given type filled with the data provided by
the given Data-Structure (a mixture of array and
Map objects). |
public static <T> T toType(Object aValue, Class<T> aType) throws InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, InvocationTargetException, ClassNotFoundException
Map
objects).T
- the generic typeaValue
- The Data-Structure, a mixture of arrays and Map
instance, from which to construct the instance of the given type.aType
- The type for which an instance is to be created.InstantiationException
- thrown when an application tries to create
an instance of a class using the newInstance method in class
Class
, but the specified class object cannot be
instantiated.IllegalAccessException
- thrown when an application tries to
reflectively create an instance (other than an array), set or get
a field, or invoke a method, but the currently executing method
does not have access to the definition of the specified class,
field, method or constructor.NoSuchMethodException
- thrown when a particular method cannot be
found.SecurityException
- thrown by the security manager to indicate a
security violation.InvocationTargetException
- wraps an exception thrown by an invoked
method or constructor.ClassNotFoundException
- thrown when an application tries to load
in a class through its string name but no definition for the
class with the specified name could be found.public static boolean isSetter(Method aMethod)
aMethod
- The Method
to be tested.public static boolean isGetter(Method aMethod)
Void
) and expect none arguments. It also must
be public.aMethod
- The Method
to be tested.public static String toPropertyName(Method aMethod)
aMethod
- The Method
which's name is to be converted to a
property name.public static String toPropertyName(Field aField)
aField
- The Field
which's name is to be converted to a
property name.Copyright © 2017. All rights reserved.