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