-
public class TAReflectUtilsReflection tool class
-
-
Method Summary
Modifier and Type Method Description static ObjectcreateObject(String className)get object class Constructor static ObjectgetObjectInstance(String className)getInstance static ObjectinvokeGetterMethod(Object obj, String propertyName)call Getter method static voidinvokeSetterMethod(Object obj, String propertyName, Object value)call Setter method static voidinvokeSetterMethod(Object obj, String propertyName, Object value, Class<out Object> propertyType)call Setter method static ObjectgetFieldValue(Object obj, String fieldName)Read object property values directly static voidsetFieldValue(Object obj, String fieldName, Object value)Set the object property value directly static FieldgetAccessibleField(Object obj, String fieldName)Loop up and get the DeclaredField of the object static ObjectinvokeMethod(Object obj, String methodName, Array<Object> args, Array<Class<out Object>> parameterTypes)static MethodgetAccessibleMethod(Object obj, String methodName, Array<Class<out Object>> parameterTypes)static <T> Class<T>getSuperClassGenericType(Class clazz)Gets the parent generic parameter type static ClassgetSuperClassGenericType(Class clazz, int index)description static voidinvokeStaticMethod(String className, String methodName, Array<Object> args, Array<Class<out Object>> parameterTypes)Reflection calls static methods -
-
Method Detail
-
createObject
static Object createObject(String className)
get object class Constructor
- Parameters:
className- class name
-
getObjectInstance
static Object getObjectInstance(String className)
getInstance
- Parameters:
className- class name
-
invokeGetterMethod
static Object invokeGetterMethod(Object obj, String propertyName)
call Getter method
- Parameters:
obj- objpropertyName- field name
-
invokeSetterMethod
static void invokeSetterMethod(Object obj, String propertyName, Object value)
call Setter method
- Parameters:
obj- objpropertyName- method namevalue- value
-
invokeSetterMethod
static void invokeSetterMethod(Object obj, String propertyName, Object value, Class<out Object> propertyType)
call Setter method
- Parameters:
obj- objpropertyName- method namevalue- valuepropertyType- property type
-
getFieldValue
static Object getFieldValue(Object obj, String fieldName)
Read object property values directly
- Parameters:
obj- objfieldName- field name
-
setFieldValue
static void setFieldValue(Object obj, String fieldName, Object value)
Set the object property value directly
- Parameters:
obj- objfieldName- field namevalue- value
-
getAccessibleField
static Field getAccessibleField(Object obj, String fieldName)
Loop up and get the DeclaredField of the object
- Parameters:
obj- objfieldName- field name
-
invokeMethod
static Object invokeMethod(Object obj, String methodName, Array<Object> args, Array<Class<out Object>> parameterTypes)
- Parameters:
obj- objmethodName- method nameargs- method parameterparameterTypes- method parameter types
-
getAccessibleMethod
static Method getAccessibleMethod(Object obj, String methodName, Array<Class<out Object>> parameterTypes)
- Parameters:
obj- objmethodName- method nameparameterTypes- method parameter types
-
getSuperClassGenericType
static <T> Class<T> getSuperClassGenericType(Class clazz)
Gets the parent generic parameter type
- Parameters:
clazz- class
-
getSuperClassGenericType
static Class getSuperClassGenericType(Class clazz, int index)
description
- Parameters:
clazz- classindex- index
-
invokeStaticMethod
static void invokeStaticMethod(String className, String methodName, Array<Object> args, Array<Class<out Object>> parameterTypes)
Reflection calls static methods
- Parameters:
className- class namemethodName- method nameargs- method parameterparameterTypes- method parameter types
-
-
-
-