public class ReflectUtil extends Object
this#getFieldsDirectly(Class, boolean) this#setFieldValue(Object, Field, Object) this#getDefaultValue(Class) | 构造器和说明 |
|---|
ReflectUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
cast(Class<?> clazz,
Object value)
Cast the value to the type
If a ClassCastException occurs, return null |
static Object |
createInstance(Class<?> cls)
get instance
|
static Object |
getDefaultValue(Class<?> clazz)
the default value is obtained if it is a primitive type, and NULL if it is not
|
static Field |
getField(Class<?> beanClass,
String name) |
static String |
getFieldName(Field field) |
static Field[] |
getFields(Class<?> beanClass) |
static Field[] |
getFieldsDirectly(Class<?> beanClass,
boolean withSuperClassFields) |
static Object |
getFieldValue(Object obj,
Field field) |
static Object |
getFieldValue(Object obj,
String fieldName) |
static Method |
getMethodByName(Class<?> clazz,
String methodName)
find the method associated with the method name
if find multiple, return the first, parameter is equivocal |
static Method |
getMethodByName(Class<?> clazz,
String methodName,
Class<?>... arguments)
find the method associated with the method name
|
static <T> T |
invoke(Object obj,
Method method,
Object... arguments)
invoke
|
static <T extends AccessibleObject> |
setAccessible(T accessibleObject) |
static void |
setFieldValue(Object obj,
Field field,
Object value) |
static void |
setFieldValue(Object obj,
String fieldName,
Object value) |
public static <T extends AccessibleObject> T setAccessible(T accessibleObject)
public static Field getField(Class<?> beanClass, String name) throws SecurityException
public static Field[] getFields(Class<?> beanClass) throws SecurityException
public static Field[] getFieldsDirectly(Class<?> beanClass, boolean withSuperClassFields) throws SecurityException
public static void setFieldValue(Object obj, String fieldName, Object value) throws IllegalException
IllegalExceptionpublic static void setFieldValue(Object obj, Field field, Object value) throws IllegalException
IllegalExceptionpublic static Method getMethodByName(Class<?> clazz, String methodName)
clazz - the classmethodName - retrieves the method namepublic static Method getMethodByName(Class<?> clazz, String methodName, Class<?>... arguments)
clazz - the classmethodName - retrieves the method namearguments - matched parameters classpublic static Object cast(Class<?> clazz, Object value)
clazz - Cast classvalue - The cast valuepublic static Object getDefaultValue(Class<?> clazz)
clazz - clazzpublic static <T> T invoke(Object obj, Method method, Object... arguments)
obj - the objmethod - the methodarguments - parametersCopyright © 2022. All rights reserved.