Package org.aoju.bus.core.scanner
Interface AnnotationScanner
- All Known Implementing Classes:
AbstractTypeScanner,FieldScanner,MetaScanner,MethodScanner,TypeScanner
public interface AnnotationScanner
注解扫描器,用于从支持的可注解元素上获取所需注解
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<Annotation> getAnnotations(AnnotatedElement annotatedEle) 获取注解元素上的全部注解。default List<Annotation> getIfSupport(AnnotatedElement annotatedEle) 若support(AnnotatedElement)返回true, 则调用并返回getAnnotations(AnnotatedElement)结果, 否则返回Collections.emptyList()default voidscan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) 扫描注解元素的层级结构(若存在),然后对获取到的注解和注解对应的层级索引进行处理。static List<Annotation> scanByAllScanner(AnnotatedElement annotatedEle, AnnotationScanner... scanners) 根据指定的扫描器,扫描元素上可能存在的注解static List<Annotation> scanByAnySupported(AnnotatedElement annotatedEle, AnnotationScanner... scanners) 给定一组扫描器,使用第一个支持处理该类型元素的扫描器获取元素上可能存在的注解default voidscanIfSupport(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) default booleansupport(AnnotatedElement annotatedEle) 判断是否支持扫描该注解元素
-
Method Details
-
scanByAnySupported
static List<Annotation> scanByAnySupported(AnnotatedElement annotatedEle, AnnotationScanner... scanners) 给定一组扫描器,使用第一个支持处理该类型元素的扫描器获取元素上可能存在的注解- Parameters:
annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionscanners- 注解扫描器- Returns:
- 注解
-
scanByAllScanner
static List<Annotation> scanByAllScanner(AnnotatedElement annotatedEle, AnnotationScanner... scanners) 根据指定的扫描器,扫描元素上可能存在的注解- Parameters:
annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionscanners- 注解扫描器- Returns:
- 注解
-
support
判断是否支持扫描该注解元素- Parameters:
annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermission- Returns:
- 是否支持扫描该注解元素
-
getIfSupport
若support(AnnotatedElement)返回true, 则调用并返回getAnnotations(AnnotatedElement)结果, 否则返回Collections.emptyList()- Parameters:
annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermission- Returns:
- 注解
-
getAnnotations
获取注解元素上的全部注解。调用该方法前,需要确保调用support(AnnotatedElement)返回为true- Parameters:
annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermission- Returns:
- 注解
-
scan
default void scan(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) 扫描注解元素的层级结构(若存在),然后对获取到的注解和注解对应的层级索引进行处理。 调用该方法前,需要确保调用support(AnnotatedElement)返回为true- Parameters:
consumer- 对获取到的注解和注解对应的层级索引的处理annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionfilter- 注解过滤器,无法通过过滤器的注解不会被处理。该参数允许为空。
-
scanIfSupport
default void scanIfSupport(BiConsumer<Integer, Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter) - Parameters:
consumer- 对获取到的注解和注解对应的层级索引的处理annotatedEle-AnnotatedElement,可以是Class、Method、Field、Constructor、ReflectPermissionfilter- 注解过滤器,无法通过过滤器的注解不会被处理。该参数允许为空。
-