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 <T> void |
toInstance(Object aValue,
T aInstance)
Updates the provided instance with the data provided by the given value
(a mixture of array and
Map objects). |
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 <T> void toInstance(Object aValue, T aInstance) throws InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, InvocationTargetException, ClassNotFoundException
Map
objects).
In case the instance to be updated represents an array, then at most it
is filled with the provided value's elements, even if the value provides
more elements than would fit. On the other hand, if the instance's array
to be updated provides room for more elements than the value can provide,
then the remaining instance's elements are left as are.T
- the generic typeaValue
- The Data-Structure, a mixture of arrays and Map
instance, from which to update the instance of the given type.aInstance
- The instance to be updated.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 © 2018. All rights reserved.