public final class ReflectionUtils
extends java.lang.Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Field |
getFieldByNameIncludingSuperclasses(java.lang.String fieldName,
java.lang.Class clazz) |
static java.util.List |
getFieldsIncludingSuperclasses(java.lang.Class clazz) |
static java.lang.reflect.Method |
getSetter(java.lang.String fieldName,
java.lang.Class clazz)
Finds a setter in the given class for the given field.
|
static java.util.List |
getSetters(java.lang.Class clazz)
Finds all setters in the given class and super classes.
|
static java.lang.Class |
getSetterType(java.lang.reflect.Method method)
Returns the class of the argument to the setter.
|
static java.lang.Object |
getValueIncludingSuperclasses(java.lang.String variable,
java.lang.Object object)
Generates a map of the fields and values on a given object,
also pulls from superclasses
|
static java.util.Map |
getVariablesAndValuesIncludingSuperclasses(java.lang.Object object)
Generates a map of the fields and values on a given object,
also pulls from superclasses
|
static boolean |
isSetter(java.lang.reflect.Method method) |
static void |
setVariableValueInObject(java.lang.Object object,
java.lang.String variable,
java.lang.Object value)
attempts to set the value to the variable in the object passed in
|
public static java.lang.reflect.Field getFieldByNameIncludingSuperclasses(java.lang.String fieldName, java.lang.Class clazz)
public static java.util.List getFieldsIncludingSuperclasses(java.lang.Class clazz)
public static java.lang.reflect.Method getSetter(java.lang.String fieldName, java.lang.Class clazz)
fieldName
- the name of the field (i.e. 'fooBar'); it will search for a method named 'setFooBar'.clazz
- The class to find the method in.public static java.util.List getSetters(java.lang.Class clazz)
public static java.lang.Class getSetterType(java.lang.reflect.Method method)
public static void setVariableValueInObject(java.lang.Object object, java.lang.String variable, java.lang.Object value) throws java.lang.IllegalAccessException
object
- variable
- value
- java.lang.IllegalAccessException
public static java.lang.Object getValueIncludingSuperclasses(java.lang.String variable, java.lang.Object object) throws java.lang.IllegalAccessException
object
- the object to generate the list of fields fromjava.lang.IllegalAccessException
public static java.util.Map getVariablesAndValuesIncludingSuperclasses(java.lang.Object object) throws java.lang.IllegalAccessException
object
- the object to generate the list of fields fromjava.lang.IllegalAccessException
public static boolean isSetter(java.lang.reflect.Method method)