77
88import java .util .ArrayList ;
99import java .util .List ;
10+ import java .util .Optional ;
1011import java .util .Set ;
12+ import javax .lang .model .element .AnnotationMirror ;
1113import javax .lang .model .element .ExecutableElement ;
1214import javax .lang .model .type .TypeMirror ;
1315
@@ -34,14 +36,16 @@ public class SubclassMappingOptions extends DelegatingOptions {
3436 private final TypeMirror target ;
3537 private final TypeUtils typeUtils ;
3638 private final SelectionParameters selectionParameters ;
39+ private final SubclassMappingGem subclassMappingGem ;
3740
3841 public SubclassMappingOptions (TypeMirror source , TypeMirror target , TypeUtils typeUtils , DelegatingOptions next ,
39- SelectionParameters selectionParameters ) {
42+ SelectionParameters selectionParameters , SubclassMappingGem subclassMappingGem ) {
4043 super ( next );
4144 this .source = source ;
4245 this .target = target ;
4346 this .typeUtils = typeUtils ;
4447 this .selectionParameters = selectionParameters ;
48+ this .subclassMappingGem = subclassMappingGem ;
4549 }
4650
4751 @ Override
@@ -124,6 +128,10 @@ public SelectionParameters getSelectionParameters() {
124128 return selectionParameters ;
125129 }
126130
131+ public AnnotationMirror getMirror () {
132+ return Optional .ofNullable ( subclassMappingGem ).map ( SubclassMappingGem ::mirror ).orElse ( null );
133+ }
134+
127135 public static void addInstances (SubclassMappingsGem gem , ExecutableElement method ,
128136 BeanMappingOptions beanMappingOptions , FormattingMessager messager ,
129137 TypeUtils typeUtils , Set <SubclassMappingOptions > mappings ,
@@ -143,13 +151,13 @@ public static void addInstances(SubclassMappingsGem gem, ExecutableElement metho
143151 }
144152 }
145153
146- public static void addInstance (SubclassMappingGem subclassMapping , ExecutableElement method ,
154+ public static void addInstance (SubclassMappingGem subclassMappingGem , ExecutableElement method ,
147155 BeanMappingOptions beanMappingOptions , FormattingMessager messager ,
148156 TypeUtils typeUtils , Set <SubclassMappingOptions > mappings ,
149157 List <Parameter > sourceParameters , Type resultType ,
150158 SubclassValidator subclassValidator ) {
151159 if ( !isConsistent (
152- subclassMapping ,
160+ subclassMappingGem ,
153161 method ,
154162 messager ,
155163 typeUtils ,
@@ -159,11 +167,11 @@ public static void addInstance(SubclassMappingGem subclassMapping, ExecutableEle
159167 return ;
160168 }
161169
162- TypeMirror sourceSubclass = subclassMapping .source ().getValue ();
163- TypeMirror targetSubclass = subclassMapping .target ().getValue ();
170+ TypeMirror sourceSubclass = subclassMappingGem .source ().getValue ();
171+ TypeMirror targetSubclass = subclassMappingGem .target ().getValue ();
164172 SelectionParameters selectionParameters = new SelectionParameters (
165- subclassMapping .qualifiedBy ().get (),
166- subclassMapping .qualifiedByName ().get (),
173+ subclassMappingGem .qualifiedBy ().get (),
174+ subclassMappingGem .qualifiedByName ().get (),
167175 targetSubclass ,
168176 typeUtils
169177 );
@@ -175,7 +183,8 @@ public static void addInstance(SubclassMappingGem subclassMapping, ExecutableEle
175183 targetSubclass ,
176184 typeUtils ,
177185 beanMappingOptions ,
178- selectionParameters
186+ selectionParameters ,
187+ subclassMappingGem
179188 ) );
180189 }
181190
@@ -190,7 +199,8 @@ public static List<SubclassMappingOptions> copyForInverseInheritance(Set<Subclas
190199 subclassMapping .source ,
191200 subclassMapping .typeUtils ,
192201 beanMappingOptions ,
193- subclassMapping .selectionParameters
202+ subclassMapping .selectionParameters ,
203+ subclassMapping .subclassMappingGem
194204 ) );
195205 }
196206 return mappings ;
0 commit comments