反射名词
Type
1  | /*  | 
Optional
1  | 
  | 
OfField<F extends TypeDescriptor.OfField> 
1  | interface OfField<F extends TypeDescriptor.OfField<F>> extends TypeDescriptor  | 
Constable
1  | 
  | 
AnnotatedElement
1  | 
  | 
| Return Type | Signature | Directly Present | Indirectly Present | Present | Associated | 
|---|---|---|---|---|---|
| {@code T} | {@link #getAnnotation(Class) getAnnotation(Class | 
X | |||
| {@code Annotation[]} | {@link #getAnnotations getAnnotations()} | X | |||
| {@code T[]} | {@link #getAnnotationsByType(Class) getAnnotationsByType(Class | 
X | |||
| {@code T} | {@link #getDeclaredAnnotation(Class) getDeclaredAnnotation(Class | 
X | |||
| {@code Annotation[]} | {@link #getDeclaredAnnotations getDeclaredAnnotations()} | X | |||
| {@code T[]} | {@link #getDeclaredAnnotationsByType(Class) getDeclaredAnnotationsByType(Class | 
X | X | 
GenericDeclaration
1  | 
  | 
Class
1  | 
  | 
EnclosingMethodInfo
1  | 
  | 
ReflectionData
1  | 
  | 
Atomic
1  | /**  | 
AnnotationData
1  | private static class AnnotationData {  | 
AccessibleObject
1  | 继承 AnnotatedElement  | 
Member
1  | Member是一个接口,它反映有关单个成员(字段或方法)或构造函数的标识信息。  | 
Executable
1  | 继承 Member AccessibleObject GenericDeclaration  | 
Constructor
1  | 继承 Executable  | 
Method
1  | 继承 Executable  | 
Field
1  | extends AccessibleObject implements Member  | 
类的构建 字段Field ,构造器Constructor, 方法Method,注解AnnotationElement,结构固定,使用访问者模式是很好的选择
访问者模式
一个东西的结构固定不变,访问其内部的方式多变时,访问者模式是首选
访问者 重在提取数据操作 ,被访问者重在 提供数据,那此时,访问者与被访问者 在两条发展线上,多态就可以应用在访问者和被访问者上
让我们来看看springframework的asm模块
1  | abstract ClassVisitor:{  | 
- 本文作者: 忘忧症
 - 本文链接: https://NepenthesZGW.github.io/2020/06/10/java/反射/
 - 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!
 
		