public class GenericAnnotationScanner extends Object implements AnnotationScanner
通用注解扫描器,支持按不同的层级结构扫描AnnotatedElement
上的注解。
当AnnotatedElement
类型不同时,“层级结构”指向的对象将有所区别:
TypeAnnotationScanner
,
MethodAnnotationScanner
,
MetaAnnotationScanner
,
ElementAnnotationScanner
DIRECTLY, DIRECTLY_AND_META_ANNOTATION, INTERFACE, INTERFACE_AND_META_ANNOTATION, NOTHING, SUPERCLASS, SUPERCLASS_AND_META_ANNOTATION, TYPE_HIERARCHY, TYPE_HIERARCHY_AND_META_ANNOTATION
Constructor and Description |
---|
GenericAnnotationScanner(boolean enableScanMetaAnnotation,
boolean enableScanSupperClass,
boolean enableScanSupperInterface)
构造一个通用注解扫描器
|
Modifier and Type | Method and Description |
---|---|
void |
scan(BiConsumer<Integer,Annotation> consumer,
AnnotatedElement annotatedEle,
Predicate<Annotation> filter)
扫描注解元素的层级结构(若存在),然后对获取到的注解和注解对应的层级索引进行处理
|
boolean |
support(AnnotatedElement annotatedEle)
通用注解扫描器支持扫描所有类型的
AnnotatedElement |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAnnotations, getAnnotationsIfSupport, scanByAllSupported, scanByAnySupported, scanIfSupport
public GenericAnnotationScanner(boolean enableScanMetaAnnotation, boolean enableScanSupperClass, boolean enableScanSupperInterface)
enableScanMetaAnnotation
- 是否扫描注解上的元注解enableScanSupperClass
- 是否扫描父类enableScanSupperInterface
- 是否扫描父接口public boolean support(AnnotatedElement annotatedEle)
AnnotatedElement
support
in interface AnnotationScanner
annotatedEle
- AnnotatedElement
,可以是Class、Method、Field、Constructor、ReflectPermissionpublic void scan(BiConsumer<Integer,Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter)
scan
in interface AnnotationScanner
consumer
- 对获取到的注解和注解对应的层级索引的处理annotatedEle
- AnnotatedElement
,可以是Class、Method、Field、Constructor、ReflectPermissionfilter
- 注解过滤器,无法通过过滤器的注解不会被处理。该参数允许为空。Copyright © 2024. All rights reserved.