1212import javax .lang .model .element .Element ;
1313import javax .lang .model .element .ElementKind ;
1414import javax .lang .model .element .TypeElement ;
15- import javax .lang .model .util .Elements ;
1615
1716import org .mapstruct .ap .internal .model .common .Accessibility ;
1817import org .mapstruct .ap .internal .model .common .Type ;
@@ -33,63 +32,24 @@ public class Mapper extends GeneratedType {
3332 static final String DEFAULT_IMPLEMENTATION_CLASS = CLASS_NAME_PLACEHOLDER + "Impl" ;
3433 static final String DEFAULT_IMPLEMENTATION_PACKAGE = PACKAGE_NAME_PLACEHOLDER ;
3534
36- private final boolean customPackage ;
37- private final boolean customImplName ;
38- private Decorator decorator ;
39-
40- @ SuppressWarnings ( "checkstyle:parameternumber" )
41- private Mapper (TypeFactory typeFactory , String packageName , String name , String superClassName ,
42- String interfacePackage , String interfaceName , boolean customPackage , boolean customImplName ,
43- List <MappingMethod > methods , Options options , VersionInformation versionInformation ,
44- Accessibility accessibility , List <Field > fields , Constructor constructor ,
45- Decorator decorator , SortedSet <Type > extraImportedTypes ) {
46-
47- super (
48- typeFactory ,
49- packageName ,
50- name ,
51- superClassName ,
52- interfacePackage ,
53- interfaceName ,
54- methods ,
55- fields ,
56- options ,
57- versionInformation ,
58- accessibility ,
59- extraImportedTypes ,
60- constructor
61- );
62- this .customPackage = customPackage ;
63- this .customImplName = customImplName ;
64-
65- this .decorator = decorator ;
66- }
67-
68- public static class Builder {
35+ public static class Builder extends GeneratedTypeBuilder <Builder > {
6936
70- private TypeFactory typeFactory ;
7137 private TypeElement element ;
72- private List <MappingMethod > mappingMethods ;
7338 private List <Field > fields ;
7439 private Set <SupportingConstructorFragment > fragments ;
75- private SortedSet <Type > extraImportedTypes ;
7640
77- private Elements elementUtils ;
78- private Options options ;
79- private VersionInformation versionInformation ;
8041 private Decorator decorator ;
8142 private String implName ;
8243 private boolean customName ;
8344 private String implPackage ;
8445 private boolean customPackage ;
8546
86- public Builder element (TypeElement element ) {
87- this .element = element ;
88- return this ;
47+ public Builder () {
48+ super ( Builder .class );
8949 }
9050
91- public Builder mappingMethods ( List < MappingMethod > mappingMethods ) {
92- this .mappingMethods = mappingMethods ;
51+ public Builder element ( TypeElement element ) {
52+ this .element = element ;
9353 return this ;
9454 }
9555
@@ -103,36 +63,11 @@ public Builder constructorFragments(Set<SupportingConstructorFragment> fragment
10363 return this ;
10464 }
10565
106- public Builder options (Options options ) {
107- this .options = options ;
108- return this ;
109- }
110-
111- public Builder versionInformation (VersionInformation versionInformation ) {
112- this .versionInformation = versionInformation ;
113- return this ;
114- }
115-
116- public Builder typeFactory (TypeFactory typeFactory ) {
117- this .typeFactory = typeFactory ;
118- return this ;
119- }
120-
121- public Builder elementUtils (Elements elementUtils ) {
122- this .elementUtils = elementUtils ;
123- return this ;
124- }
125-
12666 public Builder decorator (Decorator decorator ) {
12767 this .decorator = decorator ;
12868 return this ;
12969 }
13070
131- public Builder extraImports (SortedSet <Type > extraImportedTypes ) {
132- this .extraImportedTypes = extraImportedTypes ;
133- return this ;
134- }
135-
13671 public Builder implName (String implName ) {
13772 this .implName = implName ;
13873 this .customName = !DEFAULT_IMPLEMENTATION_CLASS .equals ( this .implName );
@@ -147,7 +82,7 @@ public Builder implPackage(String implPackage) {
14782
14883 public Mapper build () {
14984 String implementationName = implName .replace ( CLASS_NAME_PLACEHOLDER , getFlatName ( element ) ) +
150- ( decorator == null ? "" : "_" );
85+ ( decorator == null ? "" : "_" );
15186
15287 String elementPackage = elementUtils .getPackageOf ( element ).getQualifiedName ().toString ();
15388 String packageName = implPackage .replace ( PACKAGE_NAME_PLACEHOLDER , elementPackage );
@@ -164,7 +99,7 @@ public Mapper build() {
16499 element .getKind () == ElementKind .INTERFACE ? element .getSimpleName ().toString () : null ,
165100 customPackage ,
166101 customName ,
167- mappingMethods ,
102+ methods ,
168103 options ,
169104 versionInformation ,
170105 Accessibility .fromModifiers ( element .getModifiers () ),
@@ -177,6 +112,38 @@ public Mapper build() {
177112
178113 }
179114
115+ private final boolean customPackage ;
116+ private final boolean customImplName ;
117+ private Decorator decorator ;
118+
119+ @ SuppressWarnings ( "checkstyle:parameternumber" )
120+ private Mapper (TypeFactory typeFactory , String packageName , String name , String superClassName ,
121+ String interfacePackage , String interfaceName , boolean customPackage , boolean customImplName ,
122+ List <MappingMethod > methods , Options options , VersionInformation versionInformation ,
123+ Accessibility accessibility , List <Field > fields , Constructor constructor ,
124+ Decorator decorator , SortedSet <Type > extraImportedTypes ) {
125+
126+ super (
127+ typeFactory ,
128+ packageName ,
129+ name ,
130+ superClassName ,
131+ interfacePackage ,
132+ interfaceName ,
133+ methods ,
134+ fields ,
135+ options ,
136+ versionInformation ,
137+ accessibility ,
138+ extraImportedTypes ,
139+ constructor
140+ );
141+ this .customPackage = customPackage ;
142+ this .customImplName = customImplName ;
143+
144+ this .decorator = decorator ;
145+ }
146+
180147 public Decorator getDecorator () {
181148 return decorator ;
182149 }
0 commit comments