Package com.foxinmy.weixin4j.util
Class ReflectionUtil
- java.lang.Object
-
- com.foxinmy.weixin4j.util.ReflectionUtil
-
public class ReflectionUtil extends Object
- Author:
- jinyu(foxinmy@gmail.com) , 2012-10-26
-
-
Constructor Summary
Constructors Constructor Description ReflectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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/getterstatic 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
-
-
-
Method Detail
-
getFieldGenericType
public static Class<?> getFieldGenericType(Object obj, String fieldName)
获取字段的泛型参数类型- Parameters:
obj
-fieldName
-- Returns:
-
invokeMethod
public static Object invokeMethod(Object object, String propertyName)
调用方法- Parameters:
object
- 对象propertyName
- 属性名称
-
invokeGetterMethod
public static Object invokeGetterMethod(Object object, String propertyName) throws Exception
调用Getter方法- Parameters:
object
- 对象propertyName
- 属性名称- Throws:
SecurityException
NoSuchMethodException
InvocationTargetException
IllegalArgumentException
IllegalAccessException
Exception
-
invokeSetterMethod
public static void invokeSetterMethod(Object object, String propertyName, Object propertyValue)
调用Setter方法- Parameters:
object
- 对象propertyName
- 属性名称propertyValue
- 属性值
-
invokeSetterMethod
public static void invokeSetterMethod(Object object, String propertyName, Object propertyValue, Class<?> setterMethodClass)
调用Setter方法- Parameters:
object
- 对象propertyName
- 属性名称propertyValue
- 属性值setterMethodClass
- 参数类型
-
getFieldValue
public static Object getFieldValue(Object object, String fieldName)
获取对象属性值,无视private/protected/getter- Parameters:
object
- 对象fieldName
- 属性名称
-
setFieldValue
public static void setFieldValue(Object object, String fieldName, Object value)
设置对象属性值,无视private/protected/setter- Parameters:
object
- 对象fieldName
- 属性名称
-
-