1
2
3
4
5 package org.apache.maven.api.toolchain;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import org.apache.maven.api.annotations.Experimental;
12 import org.apache.maven.api.annotations.Generated;
13 import org.apache.maven.api.annotations.Immutable;
14 import org.apache.maven.api.annotations.Nonnull;
15 import org.apache.maven.api.annotations.NotThreadSafe;
16 import org.apache.maven.api.annotations.ThreadSafe;
17 import org.apache.maven.api.xml.XmlNode;
18
19
20
21
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class ToolchainModel
25 extends TrackableBase
26 implements Serializable
27 {
28
29
30
31
32
33
34
35
36 final String type;
37
38
39
40
41
42
43
44 final Map<String, String> provides;
45
46
47
48
49
50
51 final XmlNode configuration;
52
53
54
55
56
57 ToolchainModel(
58 String type,
59 Map<String, String> provides,
60 XmlNode configuration
61 )
62 {
63 super(
64 );
65 this.type = type;
66 this.provides = ImmutableCollections.copy( provides );
67 this.configuration = configuration;
68 }
69
70
71
72
73
74
75
76
77
78
79
80 public String getType()
81 {
82 return this.type;
83 }
84
85
86
87
88
89
90
91
92
93
94 @Nonnull
95 public Map<String, String> getProvides()
96 {
97 return this.provides;
98 }
99
100
101
102
103
104
105
106
107
108 public XmlNode getConfiguration()
109 {
110 return this.configuration;
111 }
112
113
114
115
116
117
118 @Nonnull
119 public Builder with()
120 {
121 return newBuilder( this );
122 }
123
124
125
126
127
128
129 @Nonnull
130 public ToolchainModel withType( String type )
131 {
132 return with().type( type ).build();
133 }
134
135
136
137
138
139
140 @Nonnull
141 public ToolchainModel withProvides( Map<String, String> provides )
142 {
143 return with().provides( provides ).build();
144 }
145
146
147
148
149
150
151 @Nonnull
152 public ToolchainModel withConfiguration( XmlNode configuration )
153 {
154 return with().configuration( configuration ).build();
155 }
156
157
158
159
160
161
162
163
164 @Nonnull
165 public static ToolchainModel newInstance()
166 {
167 return newInstance( true );
168 }
169
170
171
172
173
174
175
176
177 @Nonnull
178 public static ToolchainModel newInstance( boolean withDefaults )
179 {
180 return newBuilder( withDefaults ).build();
181 }
182
183
184
185
186
187
188
189
190 @Nonnull
191 public static Builder newBuilder()
192 {
193 return newBuilder( true );
194 }
195
196
197
198
199
200
201
202 @Nonnull
203 public static Builder newBuilder( boolean withDefaults )
204 {
205 return new Builder( withDefaults );
206 }
207
208
209
210
211
212
213
214
215 @Nonnull
216 public static Builder newBuilder( ToolchainModel from )
217 {
218 return newBuilder( from, false );
219 }
220
221
222
223
224
225
226
227
228 @Nonnull
229 public static Builder newBuilder( ToolchainModel from, boolean forceCopy )
230 {
231 return new Builder( from, forceCopy );
232 }
233
234
235
236
237
238
239 @NotThreadSafe
240 public static class Builder
241 extends TrackableBase.Builder
242 {
243 ToolchainModel base;
244 String type;
245 Map<String, String> provides;
246 XmlNode configuration;
247
248 Builder( boolean withDefaults )
249 {
250 super( withDefaults );
251 if ( withDefaults )
252 {
253 }
254 }
255
256 Builder( ToolchainModel base, boolean forceCopy )
257 {
258 super( base, forceCopy );
259 if ( forceCopy )
260 {
261 this.type = base.type;
262 this.provides = base.provides;
263 this.configuration = base.configuration;
264 }
265 else
266 {
267 this.base = base;
268 }
269 }
270
271 @Nonnull
272 public Builder type( String type )
273 {
274 this.type = type;
275 return this;
276 }
277
278 @Nonnull
279 public Builder provides( Map<String, String> provides )
280 {
281 this.provides = provides;
282 return this;
283 }
284
285 @Nonnull
286 public Builder configuration( XmlNode configuration )
287 {
288 this.configuration = configuration;
289 return this;
290 }
291
292
293 @Nonnull
294 public ToolchainModel build()
295 {
296 if ( base != null
297 && ( type == null || type == base.type )
298 && ( provides == null || provides == base.provides )
299 && ( configuration == null || configuration == base.configuration )
300 )
301 {
302 return base;
303 }
304 return new ToolchainModel(
305 type != null ? type : ( base != null ? base.type : null ),
306 provides != null ? provides : ( base != null ? base.provides : null ),
307 configuration != null ? configuration : ( base != null ? base.configuration : null )
308 );
309 }
310 }
311
312
313
314
315
316
317
318
319 public int hashCode()
320 {
321 int result = 17;
322
323 result = 37 * result + ( getType() != null ? getType().hashCode() : 0 );
324 result = 37 * result + ( getProvides() != null ? getProvides().hashCode() : 0 );
325
326 return result;
327 }
328
329
330
331
332
333
334
335 public boolean equals( Object other )
336 {
337 if ( this == other )
338 {
339 return true;
340 }
341
342 if ( !( other instanceof ToolchainModel ) )
343 {
344 return false;
345 }
346
347 ToolchainModel that = (ToolchainModel) other;
348 boolean result = true;
349
350 result = result && ( getType() == null ? that.getType() == null : getType().equals( that.getType() ) );
351 result = result && ( getProvides() == null ? that.getProvides() == null : getProvides().equals( that.getProvides() ) );
352
353 return result;
354 }
355
356
357 }