简介
使用不同注解的节点生成不同对象,对该对象的核心属性介绍,以及一些核心方法说明。
在学习的过程中最好拿一个笔对存在的问题进行记录,后面可能会找到,而且要学会不断翻阅前面的内容。如果都找不到需要的答案,我相信这个就是自身找到的亮点问题,对自身提升也有很大帮助。
节点生成的对象
ComponentDescriptor
该对象的生成在ComponentProcessingStep中继校验之后调用如下方法完成ComponentDescriptor对象的生成:
生成的是componentDescriptor对象:
//重头戏,生成ComponentDescriptor对象
ComponentDescriptor componentDescriptor =
componentDescriptorFactory.rootComponentDescriptor(component);
生成subcomponentDescriptor对象:
ComponentDescriptor subcomponentDescriptor =
componentDescriptorFactory.subcomponentDescriptor(subcomponent);
component节点生成当前对象,属性如下:
-
ComponentAnnotation annotation:当前component节点使用的注解信息,自行查看ComponentAnnotation对象;
-
TypeElement typeElement:表示component节点(或module节点);
-
ImmutableSet dependencies:componentAnnotation#dependencies里面dependency节点生成DEPENDENCY类型的ComponentRequirement对象集合,自行查看《多种类型查询总结》ComponentRequirement对象
-
ImmutableSet modules:componentAnnotation#modules的module节点,以及该module节点上moduleAnnotation#includes的module节点,自行查看ModuleDescriptor对象;
-
ImmutableMap<ExecutableElement, ComponentRequirement> dependenciesByDependencyMethod:收集componentAnnotation#dependencies中dependency节点 ①无参②返回类型不是void 方法。K:dependency无参返回类型不是void方法,V:当前方法所在dependency节点生成的ComponentRequirement对象;
-
ImmutableSet scopes:
-
(1)component节点使用Scope注解修饰的注解集合;
-
(2)如果componentAnnotation是production类型(@ProductionComponent,@ProductionSubcomponent或@ProducerModule),还会添加@ProductionScope注解;
-
ImmutableSet childComponentsDeclaredByModules:(当前component节点上componentAnnotation#modules以及moduleAnnotation#includes里面的所有module节点,如果是module节点直接使用当前module节点的)moduleAnnotation#subcomponents里面的subcomponent节点集合生成ComponentDescriptor对象;
-
ImmutableBiMap<ComponentDescriptor.ComponentMethodDescriptor, ComponentDescriptor> childComponentsDeclaredByFactoryMethods:当前component节点上返回类型是subcomponent节点的方法。K:返回类型是subcomponent节点的componentMethod方法生成的ComponentMethodDescriptor对象,V:当前方法返回类型subcomponent节点生成的ComponentDescriptor对象;
-
ImmutableBiMap<ComponentDescriptor.ComponentMethodDescriptor, ComponentDescriptor> childComponentsDeclaredByBuilderEntryPoints:返回类型是subcomponent.creator节点(Builder)的componentMethod方法。K:返回类型是subcomponent.creator节点的componentMethod方法生成该方法生成的ComponentMethodDescriptor对象,V:componentMethod方法的返回类型subcomponent节点生成的ComponentDescriptor对象;
-
ImmutableSet<ComponentDescriptor.ComponentMethodDescriptor> componentMethods:表示componentMethod的方法生成的ComponentMethodDescriptor集合,ComponentMethodDescriptor自行查看;
-
Optional creatorDescriptor:component.creator节点如果存在,那么生成一个ComponentCreatorDescriptor,自行查看《多种类型查询总结》ComponentCreatorDescriptor对象。
ComponentAnnotation对象
表示component节点使用的componentAnnotation注解生成的对象(当然了,也可能当前component节点其实是一个module节点,这部分逻辑也是一个瑕疵,为啥module节点可以作为一个伪component节点!!!)
ComponentAnnotation有两个子类:一个是RealComponentAnnotation表示这是真的componentAnnotationAll;一个是FictionalComponentAnnotation表示moduleAnnotation,属性如下
-
AnnotationMirror annotation:表示使