public final class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static Field |
getFieldByNameIncludingSuperclasses(String fieldName,
Class<?> clazz) |
static List<Field> |
getFieldsIncludingSuperclasses(Class<?> clazz) |
static Method |
getSetter(String fieldName,
Class<?> clazz)
Finds a setter in the given class for the given field.
|
static List<Method> |
getSetters(Class<?> clazz) |
static Class<?> |
getSetterType(Method method) |
static Object |
getValueIncludingSuperclasses(String variable,
Object object)
Generates a map of the fields and values on a given object, also pulls from superclasses
|
static Map<String,Object> |
getVariablesAndValuesIncludingSuperclasses(Object object)
Generates a map of the fields and values on a given object, also pulls from superclasses
|
static boolean |
isSetter(Method method) |
static void |
setVariableValueInObject(Object object,
String variable,
Object value)
attempts to set the value to the variable in the object passed in
|
public static Field getFieldByNameIncludingSuperclasses(String fieldName, Class<?> clazz)
public static List<Field> getFieldsIncludingSuperclasses(Class<?> clazz)
public static Method getSetter(String fieldName, 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 List<Method> getSetters(Class<?> clazz)
clazz
- the Classpublic static Class<?> getSetterType(Method method)
method
- the methodpublic static void setVariableValueInObject(Object object, String variable, Object value) throws IllegalAccessException
object
- see namevariable
- see namevalue
- see nameIllegalAccessException
- if errorpublic static Object getValueIncludingSuperclasses(String variable, Object object) throws IllegalAccessException
variable
- field nameobject
- the object to generate the list of fields fromIllegalAccessException
- cannot accesspublic static Map<String,Object> getVariablesAndValuesIncludingSuperclasses(Object object) throws IllegalAccessException
object
- the object to generate the list of fields fromIllegalAccessException
- cannot accesspublic static boolean isSetter(Method method)
Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.