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 FieldgetAccessibleField(Object object, String fieldName)static Set<Field>getAllField(Class<?> clazz)static Class<?>getFieldGenericType(Object obj, String fieldName)获取字段的泛型参数类型static StringgetFieldType(Object object, String fieldName)static ObjectgetFieldValue(Object object, String fieldName)获取对象属性值,无视private/protected/getterstatic StringgetPackageName(Object obj)获取包包名static ObjectinvokeGetterMethod(Object object, String propertyName)调用Getter方法static ObjectinvokeMethod(Object object, String propertyName)调用方法static ObjectinvokeMethod(Object object, String propertyName, Object... args)static voidinvokeSetterMethod(Object object, String propertyName, Object propertyValue)调用Setter方法static voidinvokeSetterMethod(Object object, String propertyName, Object propertyValue, Class<?> setterMethodClass)调用Setter方法static voidsetFieldValue(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:
SecurityExceptionNoSuchMethodExceptionInvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionException
-
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- 属性名称
-
-