public final class ReflectionHelper extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ReflectionHelper.ClassCallback
Action to take on each class.
|
static interface |
ReflectionHelper.FieldCallback
Callback interface invoked on each field in the hierarchy.
|
static interface |
ReflectionHelper.MethodCallback
Action to take on each method.
|
Modifier and Type | Method and Description |
---|---|
static void |
doWithClasses(Class<?> clazz,
ReflectionHelper.ClassCallback cc)
Perform the given callback operation on the nested (inner) classes.
|
static void |
doWithFields(Class<?> clazz,
ReflectionHelper.FieldCallback fc)
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared
fields.
|
static void |
doWithMethods(Class<?> clazz,
ReflectionHelper.MethodCallback mc)
Perform the given callback operation on all matching methods of the given class and superclasses (or given
interface and super-interfaces).
|
static Method |
findMethod(Class<?> clazz,
String name,
Class<?>... paramTypes)
Attempt to find a
Method on the supplied class with the supplied name and parameter types. |
static Object |
getField(Field f,
Object instance) |
static void |
setField(Field f,
Object instance,
Object value) |
public static void doWithClasses(Class<?> clazz, ReflectionHelper.ClassCallback cc) throws IllegalArgumentException
clazz
- class to start looking atcc
- the callback to invoke for each inner class (excluding the class itself)IllegalArgumentException
public static void doWithFields(Class<?> clazz, ReflectionHelper.FieldCallback fc) throws IllegalArgumentException
clazz
- the target class to analyzefc
- the callback to invoke for each fieldIllegalArgumentException
public static void doWithMethods(Class<?> clazz, ReflectionHelper.MethodCallback mc) throws IllegalArgumentException
bridge methods
into
account.clazz
- class to start looking atmc
- the callback to invoke for each methodIllegalArgumentException
public static Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes)
Method
on the supplied class with the supplied name and parameter types. Searches all
superclasses up to Object
.
Returns null
if no Method
can be found.
clazz
- the class to introspectname
- the name of the methodparamTypes
- the parameter types of the method (may be null
to indicate any signature)null
if none foundApache Camel