public class AnnoKit extends Object
| Constructor and Description |
|---|
AnnoKit() |
| Modifier and Type | Method and Description |
|---|---|
static <A extends Annotation> |
getAnnotation(AnnotatedElement annotationEle,
Class<A> annotationType)
获取指定注解
|
static Annotation[] |
getAnnotations(AnnotatedElement annotationEle,
boolean isCombination)
获取指定注解
|
static <T> T |
getAnnotationValue(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType)
获取指定注解默认值
如果无指定的属性方法返回null
|
static <T> T |
getAnnotationValue(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType,
String propertyName)
获取指定注解属性的值
如果无指定的属性方法返回null
|
static Map<String,Object> |
getAnnotationValueMap(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType)
获取指定注解中所有属性值
如果无指定的属性方法返回null
|
static RetentionPolicy |
getRetentionPolicy(Class<? extends Annotation> annotationType)
获取注解类的保留时间,可选值 SOURCE(源码时),CLASS(编译时),RUNTIME(运行时),默认为 CLASS
|
static ElementType[] |
getTargetType(Class<? extends Annotation> annotationType)
获取注解类可以用来修饰哪些程序元素,如 TYPE, METHOD, CONSTRUCTOR, FIELD, PARAMETER 等
|
static boolean |
isDocumented(Class<? extends Annotation> annotationType)
是否会保存到 Javadoc 文档中
|
static boolean |
isInherited(Class<? extends Annotation> annotationType)
是否可以被继承,默认为 false
|
static Element |
toCombination(AnnotatedElement annotationEle)
将指定的被注解的元素转换为组合注解元素
|
public static Element toCombination(AnnotatedElement annotationEle)
annotationEle - 注解元素public static Annotation[] getAnnotations(AnnotatedElement annotationEle, boolean isCombination)
annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionisCombination - booleanpublic static <A extends Annotation> A getAnnotation(AnnotatedElement annotationEle, Class<A> annotationType)
A - 注解类型annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型public static <T> T getAnnotationValue(AnnotatedElement annotationEle, Class<? extends Annotation> annotationType)
T - 注解值类型annotationEle - AccessibleObject,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型public static <T> T getAnnotationValue(AnnotatedElement annotationEle, Class<? extends Annotation> annotationType, String propertyName)
T - 注解值类型annotationEle - AccessibleObject,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型propertyName - 属性名,例如注解中定义了name()方法,则 此处传入namepublic static Map<String,Object> getAnnotationValueMap(AnnotatedElement annotationEle, Class<? extends Annotation> annotationType)
annotationEle - AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionannotationType - 注解类型public static RetentionPolicy getRetentionPolicy(Class<? extends Annotation> annotationType)
annotationType - 注解类public static ElementType[] getTargetType(Class<? extends Annotation> annotationType)
annotationType - 注解类public static boolean isDocumented(Class<? extends Annotation> annotationType)
annotationType - 注解类public static boolean isInherited(Class<? extends Annotation> annotationType)
annotationType - 注解类Copyright © 2020. All rights reserved.