public class ReflectionUtils extends Object
Note: Usage of this class should be limited to testing purposes only, as it violates the encapsulation principle.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectionUtils.ReflectionException |
| Modifier and Type | Method and Description |
|---|---|
static List<Class<?>> |
getClassGenerics(Class<?> clazz,
Class<?> interfaceClass)
Returns a list of distinct
Class objects representing the generics of the given class that implement the
given interface. |
static Object |
getField(Object source,
String fieldName)
Retrieves the value of the specified field from the given object.
|
static Object |
invoke(Object source,
String methodName,
Object... params)
Invokes the specified method on the given object with the provided parameters.
|
static boolean |
match(Class<?> clazz,
Class<?> interfaceClass,
Object event) |
public static Object getField(Object source, String fieldName)
source - The object from which to retrieve the field value.fieldName - The name of the field to retrieve.RuntimeException - If the specified field does not exist.public static Object invoke(Object source, String methodName, Object... params)
source - The object on which to invoke the method.methodName - The name of the method to invoke.params - The parameters to pass to the method.public static List<Class<?>> getClassGenerics(Class<?> clazz, Class<?> interfaceClass)
Class objects representing the generics of the given class that implement the
given interface.clazz - the class to retrieve the generics forinterfaceClass - the interface to retrieve the generics forClass objects representing the generics of the given class that implement the
given interfaceCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.