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, wait
forEach, spliterator
public 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 AnnotatedElement
annotationType
- 注解类型public <A extends Annotation> A getAnnotation(Class<A> annotationType)
element
上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解getAnnotation
in interface AnnotatedElement
A
- 注解类型annotationType
- 注解类型public Annotation[] getAnnotations()
element
上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解getAnnotations
in interface AnnotatedElement
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType)
element
上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解getAnnotationsByType
in interface AnnotatedElement
A
- 注解类型annotationType
- 注解类型public Annotation[] getDeclaredAnnotations()
element
直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotations
in interface AnnotatedElement
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType)
element
直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotation
in interface AnnotatedElement
A
- 注解类型annotationType
- 注解类型public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType)
element
直接声明的注解,不包含被直接声明的容器注解包括的可重复注解getDeclaredAnnotationsByType
in interface AnnotatedElement
A
- 注解类型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.