public class ReflectionHelper extends Object
| Constructor and Description |
|---|
ReflectionHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
get(Object target,
Class<?> clazz,
String fieldName)
Convenience wrapper to reflection method invoke API.
|
static Object |
get(Object target,
String fieldName)
Convenience wrapper to reflection method invoke API.
|
static Object |
getNoException(Object target,
Class<?> clazz,
String fieldName)
Convenience wrapper to reflection method invoke API.
|
static Object |
invoke(Object target,
Class<?> clazz,
String methodName,
Class[] parameterTypes,
Object... args)
Convenience wrapper to reflection method invoke API.
|
static void |
set(Object target,
Class<?> clazz,
String fieldName,
Object value)
Convenience wrapper to reflection method invoke API.
|
public static Object invoke(Object target, Class<?> clazz, String methodName, Class[] parameterTypes, Object... args)
target - object to invoke the method on (or null for static methods)clazz - class namemethodName - method nameparameterTypes - parameter types to resolve method nameargs - actual argumentsIllegalArgumentException - if method not foundIllegalStateException - for InvocationTargetException (exception in invoked method)public static Object get(Object target, String fieldName)
target - object to get field value (or null for static methods)fieldName - field nameIllegalArgumentException - if field not foundpublic static Object get(Object target, Class<?> clazz, String fieldName)
target - object to get field value (or null for static methods)clazz - class namefieldName - field nameIllegalArgumentException - if field not foundpublic static Object getNoException(Object target, Class<?> clazz, String fieldName)
target - object to get field value (or null for static methods)clazz - class namefieldName - field namepublic static void set(Object target, Class<?> clazz, String fieldName, Object value)
target - object to get field value (or null for static methods)clazz - class namefieldName - field namevalue - field valueIllegalArgumentException - if field not foundCopyright © 2018. All rights reserved.