public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnotationScanner<T>> extends Object implements AnnotationScanner
AnnotationScanner
提供基本实现Modifier and Type | Class and Description |
---|---|
static class |
AbstractTypeAnnotationScanner.JdkProxyClassConverter
若类型为jdk代理类,则尝试转换为原始被代理类
|
DIRECTLY, DIRECTLY_AND_META_ANNOTATION, INTERFACE, INTERFACE_AND_META_ANNOTATION, NOTHING, SUPERCLASS, SUPERCLASS_AND_META_ANNOTATION, TYPE_HIERARCHY, TYPE_HIERARCHY_AND_META_ANNOTATION
Modifier | Constructor and Description |
---|---|
protected |
AbstractTypeAnnotationScanner(boolean includeSuperClass,
boolean includeInterfaces,
Predicate<Class<?>> filter,
Set<Class<?>> excludeTypes)
构造一个类注解扫描器
|
Modifier and Type | Method and Description |
---|---|
T |
addConverters(UnaryOperator<Class<?>> converter)
添加转换器
|
T |
addExcludeTypes(Class<?>... excludeTypes)
添加不扫描的类型,该类型及其树结构将直接不被查找
|
protected Class<?> |
convert(Class<?> target)
若存在转换器,则使用转换器对目标类进行转换
|
protected abstract Annotation[] |
getAnnotationsFromTargetClass(AnnotatedElement source,
int index,
Class<?> targetClass)
从类上获取最终所需的目标注解
|
protected abstract Class<?> |
getClassFormAnnotatedElement(AnnotatedElement annotatedElement)
从要搜索的注解元素上获得要递归的类型
|
boolean |
isIncludeInterfaces()
是否允许扫描父接口
|
boolean |
isIncludeSuperClass()
是否允许扫描父类
|
protected boolean |
isNotNeedProcess(Set<Class<?>> accessedTypes,
Class<?> targetClass)
当前类是否不需要处理
|
void |
scan(BiConsumer<Integer,Annotation> consumer,
AnnotatedElement annotatedEle,
Predicate<Annotation> filter)
则根据广度优先递归扫描类的层级结构,并对层级结构中类/接口声明的层级索引和它们声明的注解对象进行处理
|
protected void |
scanInterfaceIfNecessary(List<Class<?>> nextClasses,
Class<?> targetClass)
若
includeInterfaces 为true ,则将目标类的父接口也添加到nextClasses |
protected void |
scanSuperClassIfNecessary(List<Class<?>> nextClassQueue,
Class<?> targetClass)
若
includeSuperClass 为true ,则将目标类的父类也添加到nextClasses |
T |
setFilter(Predicate<Class<?>> filter)
设置过滤器,若类型无法通过该过滤器,则该类型及其树结构将直接不被查找
|
protected T |
setIncludeInterfaces(boolean includeInterfaces)
是否允许扫描父接口
|
protected T |
setIncludeSuperClass(boolean includeSuperClass)
是否允许扫描父类
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAnnotations, getAnnotationsIfSupport, scanByAllSupported, scanByAnySupported, scanIfSupport, support
public boolean isIncludeSuperClass()
public boolean isIncludeInterfaces()
public T setFilter(Predicate<Class<?>> filter)
filter
- 过滤器public T addExcludeTypes(Class<?>... excludeTypes)
excludeTypes
- 不扫描的类型public T addConverters(UnaryOperator<Class<?>> converter)
converter
- 转换器AbstractTypeAnnotationScanner.JdkProxyClassConverter
protected T setIncludeSuperClass(boolean includeSuperClass)
includeSuperClass
- 是否protected T setIncludeInterfaces(boolean includeInterfaces)
includeInterfaces
- 是否public void scan(BiConsumer<Integer,Annotation> consumer, AnnotatedElement annotatedEle, Predicate<Annotation> filter)
scan
in interface AnnotationScanner
consumer
- 对获取到的注解和注解对应的层级索引的处理annotatedEle
- 注解元素filter
- 注解过滤器,无法通过过滤器的注解不会被处理。该参数允许为空。protected abstract Class<?> getClassFormAnnotatedElement(AnnotatedElement annotatedElement)
annotatedElement
- 注解元素protected abstract Annotation[] getAnnotationsFromTargetClass(AnnotatedElement source, int index, Class<?> targetClass)
source
- 最初的注解元素index
- 类的层级索引targetClass
- 类protected boolean isNotNeedProcess(Set<Class<?>> accessedTypes, Class<?> targetClass)
accessedTypes
- 访问类型targetClass
- 目标类型protected void scanInterfaceIfNecessary(List<Class<?>> nextClasses, Class<?> targetClass)
includeInterfaces
为true
,则将目标类的父接口也添加到nextClassesnextClasses
- 下一个类集合targetClass
- 目标类型protected void scanSuperClassIfNecessary(List<Class<?>> nextClassQueue, Class<?> targetClass)
includeSuperClass
为true
,则将目标类的父类也添加到nextClassesnextClassQueue
- 下一个类队列targetClass
- 目标类型Copyright © 2024. All rights reserved.