T - AnnotationMapping类型public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>> extends Object implements AnnotatedElement, Iterable<T>
支持可重复注解的增强AnnotatedElement,
功能与MetaAnnotatedElement类似,但是存在下述差异:
AnnotatedElement上——每种类型注解只能保留一个,
即当AnnotatedElement存在多个根注解有相同的元注解时,这些元注解会都会被扫描到;
AnnotatedElement可重复注解,即当当前实例指定的RepeatableAnnotationCollector
支持从AnnotatedElement上直接声明的注解中获得可重复注解时,
则将会自动将其展开直到不为容器注解为止。getAnnotation(Class)或getDeclaredAnnotation(Class)
方法获得指定类型注解时,若该类型注解存在多个,仅能尽可能获得最先被扫描到的那一个。RepeatableAnnotationCollector| Modifier and Type | Method and Description |
|---|---|
static <A extends AnnotationMapping<Annotation>> |
create(AnnotatedElement element,
BiFunction<A,Annotation,A> mappingFactory)
获取
AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象 |
static <A extends AnnotationMapping<Annotation>> |
create(RepeatableAnnotationCollector collector,
AnnotatedElement element,
BiFunction<A,Annotation,A> mappingFactory)
获取
AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象 |
boolean |
equals(Object o)
比较两个实例是否相等
|
<A extends Annotation> |
getAnnotation(Class<A> annotationType)
从
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解 |
Annotation[] |
getAnnotations()
获取
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解 |
<A extends Annotation> |
getAnnotationsByType(Class<A> annotationType)
从
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解 |
<A extends Annotation> |
getDeclaredAnnotation(Class<A> annotationType)
获取由
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解 |
Annotation[] |
getDeclaredAnnotations()
获取由
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解 |
<A extends Annotation> |
getDeclaredAnnotationsByType(Class<A> annotationType)
获取由
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解 |
AnnotatedElement |
getElement()
注解对象
|
int |
hashCode()
获取实例的哈希值
|
boolean |
isAnnotationPresent(Class<? extends Annotation> annotationType)
指定注解是否在
element上直接声明的注解、直接声明的注解包含的可重复注解,
以及他们的元注解中存在 |
Iterator<T> |
iterator()
获取迭代器
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic static <A extends AnnotationMapping<Annotation>> RepeatableMetaAnnotatedElement<A> create(AnnotatedElement element, BiFunction<A,Annotation,A> mappingFactory)
AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象A - AnnotationMapping类型element - 被注解元素mappingFactory - 创建AnnotationMapping的工厂方法,返回值为null时将忽略该注解AnnotatedElement上的注解结构public static <A extends AnnotationMapping<Annotation>> RepeatableMetaAnnotatedElement<A> create(RepeatableAnnotationCollector collector, AnnotatedElement element, BiFunction<A,Annotation,A> mappingFactory)
AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象A - AnnotationMapping类型collector - 可重复注解收集器element - 被注解元素mappingFactory - 创建AnnotationMapping的工厂方法,返回值为null时将忽略该注解AnnotatedElement上的注解结构public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
element上直接声明的注解、直接声明的注解包含的可重复注解,
以及他们的元注解中存在isAnnotationPresent in interface AnnotatedElementannotationType - 注解类型public <A extends Annotation> A getAnnotation(Class<A> annotationType)
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解getAnnotation in interface AnnotatedElementA - 注解类型annotationType - 注解类型public Annotation[] getAnnotations()
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解getAnnotations in interface AnnotatedElementpublic <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType)
element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解getAnnotationsByType in interface AnnotatedElementA - 注解类型annotationType - 注解类型public Annotation[] getDeclaredAnnotations()
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotations in interface AnnotatedElementpublic <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType)
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotation in interface AnnotatedElementA - 注解类型annotationType - 注解类型public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType)
element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotationsByType in interface AnnotatedElementA - 注解类型annotationType - 注解类型public AnnotatedElement getElement()
public boolean equals(Object o)
public Iterator<T> iterator()
iterator in interface Iterable<T extends AnnotationMapping<Annotation>>Copyright © 2025. All rights reserved.