public class GenericAnnotationScanner extends AbstractAnnotationScanner
注解扫描器,用于从指定的AnnotatedElement及其可能存在的层级结构中获取注解对象
是AbstractAnnotationScanner的基本实现。在该抽象类的基础上,定义了支持扫描的AnnotatedElement层级结构:
Class、且Class.isAnnotation()返回false时,
此处层级结构即指类本身与其父类、父接口共同构成的层级结构,
扫描器将扫描层级结构中类、接口声明的注解;
Class、且Class.isAnnotation()返回true时,
此处层级结构指注解类及其元注解构成的层级结构,
扫描器将扫描器该注解层级结构中的元注解,并对其进行处理;
Method时,此处层级结构指声明该方法的类的层级结构,
扫描器将从层级结构中寻找与该方法签名相同的非桥接方法,并对其进行扫描;
Field时,此处层级结构指声明该属性的类的层级结构,
扫描器将从层级结构中寻找该属性,并对其注解进行扫描;
AbstractAnnotationScanner.ContextHORIZONTAL_INDEX_START_POINT, options, VERTICAL_INDEX_START_POINT| 限定符 | 构造器和说明 |
|---|---|
|
GenericAnnotationScanner(boolean enableScanSuperClass,
boolean enableScanInterface,
boolean enableScanMetaAnnotation)
|
protected |
GenericAnnotationScanner(ScanOptions options)
构造一个通用注解扫描器
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
collectAnnotationTypeIfNecessary(List<Class<?>> nextTypeHierarchies,
Class<?> type)
若
ScanOptions#isEnableScanMetaAnnotation为true,则将目标类元注解也添加到队列 |
protected void |
collectInterfaceTypeIfNecessary(List<Class<?>> nextTypeHierarchies,
Class<?> type)
若
ScanOptions#isEnableScanInterface为true,则将目标类的父接口也添加到队列 |
protected void |
collectSuperTypeIfNecessary(List<Class<?>> nextTypeHierarchies,
Class<?> type)
若
ScanOptions#isEnableScanSuperClass为true,则将目标类的父类也添加到队列 |
protected Annotation[] |
getAnnotationFromType(Class<?> type,
Class<?> element)
从类获取注解对象
|
protected Annotation[] |
getAnnotationsFromTypeDeclaredField(Class<?> type,
Field element)
从类中的指定属性获取注解对象
|
protected Annotation[] |
getAnnotationsFromTypeDeclaredMethod(Class<?> type,
Method element)
从类中的指定方法获取注解对象
|
copyOptions, scanpublic GenericAnnotationScanner(boolean enableScanSuperClass,
boolean enableScanInterface,
boolean enableScanMetaAnnotation)
enableScanSuperClass - 是否扫描父类enableScanInterface - 是否扫描接口enableScanMetaAnnotation - 是否扫描父类protected GenericAnnotationScanner(ScanOptions options)
options - 扫描配置protected void collectAnnotationTypeIfNecessary(List<Class<?>> nextTypeHierarchies, Class<?> type)
ScanOptions#isEnableScanMetaAnnotation为true,则将目标类元注解也添加到队列collectAnnotationTypeIfNecessary 在类中 AbstractAnnotationScannernextTypeHierarchies - 下一层级待处理的类队列type - 当前正在处理的类对象protected void collectInterfaceTypeIfNecessary(List<Class<?>> nextTypeHierarchies, Class<?> type)
ScanOptions#isEnableScanInterface为true,则将目标类的父接口也添加到队列collectInterfaceTypeIfNecessary 在类中 AbstractAnnotationScannernextTypeHierarchies - 下一层级待处理的类队列type - 当前正在处理的类对象protected void collectSuperTypeIfNecessary(List<Class<?>> nextTypeHierarchies, Class<?> type)
ScanOptions#isEnableScanSuperClass为true,则将目标类的父类也添加到队列collectSuperTypeIfNecessary 在类中 AbstractAnnotationScannernextTypeHierarchies - 下一层级待处理的类队列type - 当前正在处理的类对象protected Annotation[] getAnnotationsFromTypeDeclaredField(Class<?> type, Field element)
getAnnotationsFromTypeDeclaredField 在类中 AbstractAnnotationScannertype - 当前正在处理的类对象element - 最开始扫描的对象protected Annotation[] getAnnotationsFromTypeDeclaredMethod(Class<?> type, Method element)
getAnnotationsFromTypeDeclaredMethod 在类中 AbstractAnnotationScannertype - 当前正在处理的类对象element - 最开始扫描的对象protected Annotation[] getAnnotationFromType(Class<?> type, Class<?> element)
getAnnotationFromType 在类中 AbstractAnnotationScannertype - 当前正在处理的类对象element - 最开始扫描的对象Copyright © 2022. All rights reserved.