|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.baidu.unbiz.fluentvalidator.util.ReflectionUtil
public class ReflectionUtil
反射工具类
| 构造方法摘要 | |
|---|---|
ReflectionUtil()
|
|
| 方法摘要 | ||
|---|---|---|
static
|
getAnnotation(Field field,
Class<A> annotationType)
获取 Field上的注解 |
|
static Field[] |
getAnnotationFields(Class<?> clazz,
Class<? extends Annotation> annotationClass)
获取所有包含指定 Annotation的Field数组 |
|
static Method |
getGetterMethod(Class<?> clazz,
Field field)
获取getter方法 |
|
static String |
getGetterMethodName(Field field)
获取getter方法名 |
|
static Method |
getMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
获取方法 |
|
static boolean |
hasSuperClass(Class<?> clazz)
判断是否有超类 |
|
static
|
invokeMethod(Method method,
Object target,
Object... args)
方法调用,如果 clazz为null,返回null;
如果method为null,返回null
如果target为null,则为静态方法 |
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public ReflectionUtil()
| 方法详细信息 |
|---|
public static Field[] getAnnotationFields(Class<?> clazz,
Class<? extends Annotation> annotationClass)
Annotation的Field数组
clazz - 查找类annotationClass - 注解类名
Field数组
public static <A extends Annotation> A getAnnotation(Field field,
Class<A> annotationType)
Field上的注解
field - 属性annotationType - 注解类型
public static boolean hasSuperClass(Class<?> clazz)
clazz - 目标类
true,否则返回false
public static Method getGetterMethod(Class<?> clazz,
Field field)
clazz - 类field - 属性
public static String getGetterMethodName(Field field)
field - 属性
public static Method getMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
clazz - 类methodName - 方法名parameterTypes - 方法参数
public static <T> T invokeMethod(Method method,
Object target,
Object... args)
clazz为null,返回null;
如果method为null,返回null
如果target为null,则为静态方法
method - 调用的方法target - 目标对象args - 方法的参数值
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||