@@ -26,13 +26,53 @@ import org.mapstruct.tools.gem.GemValue;
2626import ${importItem} ;
2727</#list >
2828
29- public class ${gemInfo.gemName} {
29+ public class ${gemInfo.gemName} implements Gem {
3030
31- public static ${gemInfo.annotationName} instanceOn(Element element) {
31+ <#list gemInfo.gemValueInfos as gemValueInfo >
32+ private final GemValue<${gemValueInfo.valueType.name} > ${gemValueInfo.name} ;
33+ </#list >
34+ private final boolean isValid;
35+ private final AnnotationMirror mirror;
36+
37+ private ${gemInfo.gemName} ( ${gemInfo.builderImplName} builder ) {
38+ <#list gemInfo.gemValueInfos as gemValueInfo >
39+ this.${gemValueInfo.name} = builder.${gemValueInfo.name} ;
40+ </#list >
41+ <#list gemInfo.gemValueInfos as gemValueInfo >
42+ <#if gemValueInfo_index == 0 >isValid = <#else > && </#if >( this.${gemValueInfo.name} != null ? this.${gemValueInfo.name} .isValid() : false )<#if !(gemValueInfo_has_next) >;</#if >
43+ </#list >
44+ <#if gemInfo.gemValueInfos?size==0 >
45+ isValid = true;
46+ </#if >
47+ mirror = builder.mirror;
48+ }
49+
50+ <#list gemInfo.gemValueInfos as gemValueInfo >
51+ /**
52+ * accessor
53+ *
54+ * @return the {@link GemValue} for {@link ${gemInfo.gemName} #${gemValueInfo.name} }
55+ */
56+ public GemValue<${gemValueInfo.valueType.name} > ${gemValueInfo.name} ( ) {
57+ return ${gemValueInfo.name} ;
58+ }
59+
60+ </#list >
61+ @Override
62+ public AnnotationMirror mirror( ) {
63+ return mirror;
64+ }
65+
66+ @Override
67+ public boolean isValid( ) {
68+ return isValid;
69+ }
70+
71+ public static ${gemInfo.gemName} instanceOn(Element element) {
3272 return build( element, new ${gemInfo.builderImplName} () );
3373 }
3474
35- public static ${gemInfo.annotationName } instanceOn(AnnotationMirror mirror ) {
75+ public static ${gemInfo.gemName } instanceOn(AnnotationMirror mirror ) {
3676 return build( mirror, new ${gemInfo.builderImplName} () );
3777 }
3878
@@ -103,9 +143,9 @@ public class ${gemInfo.gemName} {
103143
104144 <#list gemInfo.gemValueInfos as gemValueInfo >
105145 /**
106- * Sets the {@link GemValue} for {@link ${gemInfo.annotationName } #${gemValueInfo.name} }
146+ * Sets the {@link GemValue} for {@link ${gemInfo.gemName } #${gemValueInfo.name} }
107147 *
108- * @return the {@link ${gemInfo.builderName} } for this gem, representing {@link ${gemInfo.annotationName } }
148+ * @return the {@link ${gemInfo.builderName} } for this gem, representing {@link ${gemInfo.gemName } }
109149 */
110150 ${gemInfo.builderName} set${gemValueInfo.name?capitalize } (GemValue<${gemValueInfo.valueType.name} > methodName );
111151
@@ -115,7 +155,7 @@ public class ${gemInfo.gemName} {
115155 *
116156 * @parameter mirror the mirror which this gem represents
117157 *
118- * @return the {@link ${gemInfo.builderName} } for this gem, representing {@link ${gemInfo.annotationName } }
158+ * @return the {@link ${gemInfo.builderName} } for this gem, representing {@link ${gemInfo.gemName } }
119159 */
120160 ${gemInfo.builderName} setMirror( AnnotationMirror mirror );
121161
@@ -128,7 +168,7 @@ public class ${gemInfo.gemName} {
128168 T build();
129169 }
130170
131- private static class ${gemInfo.builderImplName} implements ${gemInfo.builderName} <${gemInfo.annotationName } > {
171+ private static class ${gemInfo.builderImplName} implements ${gemInfo.builderName} <${gemInfo.gemName } > {
132172
133173 <#list gemInfo.gemValueInfos as gemValueInfo >
134174 private GemValue<${gemValueInfo.valueType.name} > ${gemValueInfo.name} ;
@@ -147,51 +187,8 @@ public class ${gemInfo.gemName} {
147187 return this;
148188 }
149189
150- public ${gemInfo.annotationName} build() {
151- return new ${gemInfo.annotationName} ( this );
152- }
153- }
154-
155- public static class ${gemInfo.annotationName} implements Gem {
156-
157- <#list gemInfo.gemValueInfos as gemValueInfo >
158- private final GemValue<${gemValueInfo.valueType.name} > ${gemValueInfo.name} ;
159- </#list >
160- private final boolean isValid;
161- private final AnnotationMirror mirror;
162-
163- private ${gemInfo.annotationName} ( ${gemInfo.builderImplName} builder ) {
164- <#list gemInfo.gemValueInfos as gemValueInfo >
165- this.${gemValueInfo.name} = builder.${gemValueInfo.name} ;
166- </#list >
167- <#list gemInfo.gemValueInfos as gemValueInfo >
168- <#if gemValueInfo_index == 0 >isValid = <#else > && </#if >( this.${gemValueInfo.name} != null ? this.${gemValueInfo.name} .isValid() : false )<#if !(gemValueInfo_has_next) >;</#if >
169- </#list >
170- <#if gemInfo.gemValueInfos?size==0 >
171- isValid = true;
172- </#if >
173- mirror = builder.mirror;
174- }
175-
176- <#list gemInfo.gemValueInfos as gemValueInfo >
177- /**
178- * accessor
179- *
180- * @return the {@link GemValue} for {@link ${gemInfo.annotationName} #${gemValueInfo.name} }
181- */
182- public GemValue<${gemValueInfo.valueType.name} > ${gemValueInfo.name} ( ) {
183- return ${gemValueInfo.name} ;
184- }
185-
186- </#list >
187- @Override
188- public AnnotationMirror mirror( ) {
189- return mirror;
190- }
191-
192- @Override
193- public boolean isValid( ) {
194- return isValid;
190+ public ${gemInfo.gemName} build() {
191+ return new ${gemInfo.gemName} ( this );
195192 }
196193 }
197194
0 commit comments