Class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>>
java.lang.Object
org.miaixz.bus.core.lang.annotation.resolve.elements.RepeatableMetaAnnotatedElement<T>
- Type Parameters:
T- AnnotationMapping类型
- All Implemented Interfaces:
Iterable<T>,AnnotatedElement
public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>>
extends Object
implements AnnotatedElement, Iterable<T>
支持可重复注解的增强AnnotatedElement, 功能与MetaAnnotatedElement类似,但是存在下述差异:
- 限制以同一根注解延伸出的树结构上——而不是
AnnotatedElement上——每种类型注解只能保留一个, 即当AnnotatedElement存在多个根注解有相同的元注解时,这些元注解会都会被扫描到; - 支持扫描
AnnotatedElement可重复注解,即当当前实例指定的RepeatableAnnotationCollector支持从AnnotatedElement上直接声明的注解中获得可重复注解时, 则将会自动将其展开直到不为容器注解为止。 eg: A上存在注解X,该注解是一个容器注解,内部可重复注解Y, 包含解析后,得到注解X与可重复注解Y, 同理,若存在X、Y、X的嵌套关系,则解析后获得全部三者;
getAnnotation(Class)或getDeclaredAnnotation(Class)
方法获得指定类型注解时,若该类型注解存在多个,仅能尽可能获得最先被扫描到的那一个。- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends AnnotationMapping<Annotation>>
RepeatableMetaAnnotatedElement<A> create(AnnotatedElement element, BiFunction<A, Annotation, A> mappingFactory) 获取AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象static <A extends AnnotationMapping<Annotation>>
RepeatableMetaAnnotatedElement<A> create(RepeatableAnnotationCollector collector, AnnotatedElement element, BiFunction<A, Annotation, A> mappingFactory) 获取AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象boolean比较两个实例是否相等<A extends Annotation>
AgetAnnotation(Class<A> annotationType) 从element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解获取element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解<A extends Annotation>
A[]getAnnotationsByType(Class<A> annotationType) 从element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解<A extends Annotation>
AgetDeclaredAnnotation(Class<A> annotationType) 获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解<A extends Annotation>
A[]getDeclaredAnnotationsByType(Class<A> annotationType) 获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解注解对象inthashCode()获取实例的哈希值booleanisAnnotationPresent(Class<? extends Annotation> annotationType) 指定注解是否在element上直接声明的注解、直接声明的注解包含的可重复注解, 以及他们的元注解中存在iterator()获取迭代器Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
create
public static <A extends AnnotationMapping<Annotation>> RepeatableMetaAnnotatedElement<A> create(AnnotatedElement element, BiFunction<A, Annotation, A> mappingFactory) 获取AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象- Type Parameters:
A-AnnotationMapping类型- Parameters:
element- 被注解元素mappingFactory- 创建AnnotationMapping的工厂方法,返回值为null时将忽略该注解- Returns:
AnnotatedElement上的注解结构
-
create
public static <A extends AnnotationMapping<Annotation>> RepeatableMetaAnnotatedElement<A> create(RepeatableAnnotationCollector collector, AnnotatedElement element, BiFunction<A, Annotation, A> mappingFactory) 获取AnnotatedElement上的注解结构,该方法会针对相同的AnnotatedElement缓存映射对象- Type Parameters:
A-AnnotationMapping类型- Parameters:
collector- 可重复注解收集器element- 被注解元素mappingFactory- 创建AnnotationMapping的工厂方法,返回值为null时将忽略该注解- Returns:
AnnotatedElement上的注解结构
-
isAnnotationPresent
指定注解是否在element上直接声明的注解、直接声明的注解包含的可重复注解, 以及他们的元注解中存在- Specified by:
isAnnotationPresentin interfaceAnnotatedElement- Parameters:
annotationType- 注解类型- Returns:
- 是否
-
getAnnotation
从element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解- Specified by:
getAnnotationin interfaceAnnotatedElement- Type Parameters:
A- 注解类型- Parameters:
annotationType- 注解类型- Returns:
- 注解
-
getAnnotations
获取element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解- Specified by:
getAnnotationsin interfaceAnnotatedElement- Returns:
- 注解
-
getAnnotationsByType
从element上直接声明的注解、直接声明的注解包含的可重复注解,以及它们的元注解中获得指定类型的注解- Specified by:
getAnnotationsByTypein interfaceAnnotatedElement- Type Parameters:
A- 注解类型- Parameters:
annotationType- 注解类型- Returns:
- 注解
-
getDeclaredAnnotations
获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解- Specified by:
getDeclaredAnnotationsin interfaceAnnotatedElement- Returns:
- 注解
-
getDeclaredAnnotation
获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解- Specified by:
getDeclaredAnnotationin interfaceAnnotatedElement- Type Parameters:
A- 注解类型- Parameters:
annotationType- 注解类型- Returns:
- 注解
-
getDeclaredAnnotationsByType
获取由element直接声明的注解,不包含被直接声明的容器注解包括的可重复注解- Specified by:
getDeclaredAnnotationsByTypein interfaceAnnotatedElement- Type Parameters:
A- 注解类型- Parameters:
annotationType- 注解类型- Returns:
- 注解
-
getElement
注解对象- Returns:
- 被包装的原始元素
-
equals
比较两个实例是否相等 -
hashCode
public int hashCode()获取实例的哈希值 -
iterator
获取迭代器- Specified by:
iteratorin interfaceIterable<T extends AnnotationMapping<Annotation>>- Returns:
- 迭代器
-