public class ReflectionUtils extends Object
Description:
| 构造器和说明 |
|---|
ReflectionUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Field |
getAccessibleField(Object object,
String fieldName) |
static Set<Field> |
getAllField(Class<?> clazz) |
static Class<?> |
getFieldGenericType(Object obj,
String fieldName)
获取字段的泛型参数类型
|
static String |
getFieldType(Object object,
String fieldName) |
static Object |
getFieldValue(Object object,
String fieldName)
获取对象属性值,无视private/protected/getter
|
static String |
getPackageName(Object obj)
获取包包名
|
static Object |
invokeGetterMethod(Object object,
String propertyName)
调用Getter方法
|
static Object |
invokeMethod(Object object,
String propertyName)
调用方法
|
static Object |
invokeMethod(Object object,
String propertyName,
Object... args) |
static void |
invokeSetterMethod(Object object,
String propertyName,
Object propertyValue)
调用Setter方法
|
static void |
invokeSetterMethod(Object object,
String propertyName,
Object propertyValue,
Class<?> setterMethodClass)
调用Setter方法
|
static void |
setFieldValue(Object object,
String fieldName,
Object value)
设置对象属性值,无视private/protected/setter
|
public static Class<?> getFieldGenericType(Object obj, String fieldName)
obj - fieldName - public static Object invokeMethod(Object object, String propertyName)
object - 对象propertyName - 属性名称public static Object invokeGetterMethod(Object object, String propertyName) throws Exception
object - 对象propertyName - 属性名称SecurityExceptionNoSuchMethodExceptionInvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionExceptionpublic static void invokeSetterMethod(Object object, String propertyName, Object propertyValue)
object - 对象propertyName - 属性名称propertyValue - 属性值public static void invokeSetterMethod(Object object, String propertyName, Object propertyValue, Class<?> setterMethodClass)
object - 对象propertyName - 属性名称propertyValue - 属性值setterMethodClass - 参数类型public static Object getFieldValue(Object object, String fieldName)
object - 对象fieldName - 属性名称public static void setFieldValue(Object object, String fieldName, Object value)
object - 对象fieldName - 属性名称Copyright © 2019. All rights reserved.