public final class InvokableReflectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
getValueForStaticField(Class targetClass,
String fieldName)
It gets value for static field by name from target class.
|
static <T> T |
getValueOfField(Object targetObject,
Class targetClass,
String fieldName)
It gets value for given field name from target object.
|
static <T> T |
getValueOfField(Object targetObject,
String fieldName)
It gets value for given field name from target object.
|
static <T> T |
invokeMethod(Object target,
Class<?> targetClass,
String methodName,
List<Class<?>> argClasses,
List<Object> args)
Invokes first match method in hierarchy starting from target class, it invoke on target object which has arguments with explicitly provided
types, and invoke method with list of arguments.
|
static <T> T |
invokeMethod(Object target,
Class<?> targetClass,
String methodName,
List<Object> args)
Invoke first match method in hierarchy starting from target class, it invoke on target object which has arguments with expected
types, and invokes method with list of arguments.
|
static <T> T |
invokeMethod(Object target,
Class<?> targetClass,
String methodName,
Object... args)
Invoke first match method in hierarchy starting from target class, it invoke on target object which has arguments with expected
types, and invokes method with list of arguments.
|
static <T> T |
invokeMethod(Object target,
String methodName,
List<Class<?>> argClasses,
List<Object> args)
Invokes first match method in hierarchy of target object which has arguments with explicitly provided
types, and invoke method with list of arguments.
|
static <T> T |
invokeMethod(Object target,
String methodName,
List<Object> args)
Invokes first match method in hierarchy of target object which has arguments with expected
types, and invokes method with list of arguments.
|
static <T> T |
invokeMethod(Object target,
String methodName,
Object... args)
Invoke first match method in hierarchy of target object which has arguments with expected
types, and invokes method with array of arguments.
|
static <T> T |
invokeStaticMethod(Class<?> targetClass,
String methodName,
List<Class<?>> argClasses,
List<Object> args)
It will search for first match static method, it will start searching from target class.
|
static <T> T |
invokeStaticMethod(Class<?> targetClass,
String methodName,
List<Object> args)
It will search for first match static method, it will start searching from target class.
|
static <T> T |
invokeStaticMethod(Class<?> targetClass,
String methodName,
Object... args)
It will search for first match static method, it will start searching from target class.
|
static <T> T |
newInstance(Class<T> type)
It create instance of object without constructor arguments.
|
static <T> T |
newInstance(Class<T> type,
List<Class<?>> argsClasses,
List<Object> args)
It create instance of object based on below arguments.
|
static <T> T |
newInstance(Class<T> type,
List<Class<?>> argsClasses,
Object... args)
It create instance of object based on below arguments.
|
static <T> T |
newInstance(Class<T> type,
List<Object> args)
It create instance of object based on below arguments.
|
static <T> T |
newInstance(Class<T> type,
Object... args)
It create instance of object based on below arguments.
|
static void |
setValueForField(Object targetObject,
Class<?> targetClass,
String fieldName,
Object newValue)
Setup new value for target object for given field name.
|
static void |
setValueForField(Object targetObject,
String fieldName,
Object newValue)
Setup new value for target object for given field name.
|
static void |
setValueForStaticField(Class<?> targetClass,
String fieldName,
Object newValue)
It can't override primitive static final fields and static final String fields.
|
public static void setValueForField(Object targetObject, String fieldName, Object newValue)
targetObject - reference for object for which will be changed valuefieldName - field namenewValue - new value for set.public static void setValueForField(Object targetObject, Class<?> targetClass, String fieldName, Object newValue)
Some interesting links below: * @see Stackoverflow thread: Change private static final field using Java reflection * @see Constant Expressions
targetObject - reference for object for which will be changed valuetargetClass - target class from which will start looking for field with that name.fieldName - field namenewValue - new value for set.public static void setValueForStaticField(Class<?> targetClass, String fieldName, Object newValue)
Some interesting links below: * @see Stackoverflow thread: Change private static final field using Java reflection * @see Constant Expressions
targetClass - class for which will be changed static fieldfieldName - name of static fieldnewValue - new value for static field.public static <T> T getValueOfField(Object targetObject, String fieldName)
T - expected return typetargetObject - target objectfieldName - field namepublic static <T> T getValueOfField(Object targetObject, Class targetClass, String fieldName)
T - expected return typetargetObject - target objecttargetClass - target classfieldName - field namepublic static <T> T getValueForStaticField(Class targetClass, String fieldName)
T - expected return typetargetClass - target classfieldName - field namepublic static <T> T invokeMethod(Object target, String methodName, List<Class<?>> argClasses, List<Object> args)
T - type of returned object.target - on that instance will be invoked methodmethodName - name of method.argClasses - explicit list of classes of arguments.args - list of arguments for method.public static <T> T invokeMethod(Object target, String methodName, List<Object> args)
T - type of returned object.target - on that instance will be invoked methodmethodName - name of method.args - list of arguments for method.public static <T> T invokeMethod(Object target, String methodName, Object... args)
T - type of returned object.target - on that instance will be invoked methodmethodName - name of method.args - list of arguments for method.public static <T> T invokeMethod(Object target, Class<?> targetClass, String methodName, List<Object> args)
T - type of returned object.target - on that instance will be invoked methodtargetClass - from this class will start searching for match method.methodName - name of method.args - list of arguments for method.public static <T> T invokeMethod(Object target, Class<?> targetClass, String methodName, Object... args)
T - type of returned object.target - on that instance will be invoked methodtargetClass - from this class will start searching for match method.methodName - name of method.args - array of arguments for method.public static <T> T invokeMethod(Object target, Class<?> targetClass, String methodName, List<Class<?>> argClasses, List<Object> args)
T - type of returned object.target - on that instance will be invoked methodtargetClass - from this class will start searching for match method.methodName - name of method.argClasses - explicit list of classes of arguments.args - list of arguments for method.public static <T> T invokeStaticMethod(Class<?> targetClass, String methodName, List<Class<?>> argClasses, List<Object> args)
T - type of returned object.targetClass - from this class will start searching for match method.methodName - name of method.argClasses - explicit list of classes of arguments.args - list of arguments for method.public static <T> T invokeStaticMethod(Class<?> targetClass, String methodName, List<Object> args)
T - type of returned object.targetClass - from this class will start searching for match method.methodName - name of method.args - list of arguments for method.public static <T> T invokeStaticMethod(Class<?> targetClass, String methodName, Object... args)
T - type of returned object.targetClass - from this class will start searching for match method.methodName - name of method.args - array of arguments for method.public static <T> T newInstance(Class<T> type, List<Class<?>> argsClasses, List<Object> args)
T - expected type of create objecttype - expected typeargsClasses - list with every type for every constructor argument.args - list with every constructor argument.public static <T> T newInstance(Class<T> type, List<Class<?>> argsClasses, Object... args)
T - expected type of create objecttype - expected typeargsClasses - list with every type for every constructor argument.args - array with every constructor argument.public static <T> T newInstance(Class<T> type, List<Object> args)
T - expected type of create objecttype - expected typeargs - list with every constructor argument.public static <T> T newInstance(Class<T> type, Object... args)
T - expected type of create objecttype - expected typeargs - array with every constructor argument.public static <T> T newInstance(Class<T> type)
T - expected type of create objecttype - expected typeCopyright © 2019. All rights reserved.