public class AnnotationUtil
extends java.lang.Object
| 构造器和说明 |
|---|
AnnotationUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <A extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<A> annotationType)
获取指定注解
|
static java.lang.annotation.Annotation[] |
getAnnotations(java.lang.reflect.AnnotatedElement annotationEle,
boolean isCombination)
获取指定注解
|
static <T> T |
getAnnotationValue(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
获取指定注解默认值
如果无指定的属性方法返回null |
static <T> T |
getAnnotationValue(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String propertyName)
获取指定注解属性的值
如果无指定的属性方法返回null |
static java.util.Map<java.lang.String,java.lang.Object> |
getAnnotationValueMap(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
获取指定注解中所有属性值
如果无指定的属性方法返回null |
static java.lang.annotation.RetentionPolicy |
getRetentionPolicy(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
获取注解类的保留时间,可选值 SOURCE(源码时),CLASS(编译时),RUNTIME(运行时),默认为 CLASS
|
static java.lang.annotation.ElementType[] |
getTargetType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
获取注解类可以用来修饰哪些程序元素,如 TYPE, METHOD, CONSTRUCTOR, FIELD, PARAMETER 等
|
static boolean |
isDocumented(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
是否会保存到 Javadoc 文档中
|
static boolean |
isInherited(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
是否可以被继承,默认为 false
|
static CombinationAnnotationElement |
toCombination(java.lang.reflect.AnnotatedElement annotationEle)
将指定的被注解的元素转换为组合注解元素
|
public static CombinationAnnotationElement toCombination(java.lang.reflect.AnnotatedElement annotationEle)
annotationEle - 注解元素public static java.lang.annotation.Annotation[] getAnnotations(java.lang.reflect.AnnotatedElement annotationEle,
boolean isCombination)
annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionpublic static <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<A> annotationType)
A - 注解类型annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型public static <T> T getAnnotationValue(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
throws UtilException
T - 注解值类型annotationEle - AccessibleObject,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型UtilException - 调用注解中的方法时执行异常public static <T> T getAnnotationValue(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String propertyName)
throws UtilException
T - 注解值类型annotationEle - AccessibleObject,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型propertyName - 属性名,例如注解中定义了name()方法,则 此处传入nameUtilException - 调用注解中的方法时执行异常public static java.util.Map<java.lang.String,java.lang.Object> getAnnotationValueMap(java.lang.reflect.AnnotatedElement annotationEle,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
throws UtilException
annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型UtilException - 调用注解中的方法时执行异常public static java.lang.annotation.RetentionPolicy getRetentionPolicy(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType - 注解类public static java.lang.annotation.ElementType[] getTargetType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType - 注解类public static boolean isDocumented(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType - 注解类public static boolean isInherited(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType - 注解类Copyright © 2018. All rights reserved.