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 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 return this.type;
81 }
82
83
84
85
86
87
88
89
90
91
92 @Nonnull
93 public Map<String, String> getProvides() {
94 return this.provides;
95 }
96
97
98
99
100
101
102
103
104
105 public XmlNode getConfiguration() {
106 return this.configuration;
107 }
108
109
110
111
112
113
114 @Nonnull
115 public Builder with() {
116 return newBuilder(this);
117 }
118
119
120
121
122
123
124 @Nonnull
125 public ToolchainModel withType(String type) {
126 return newBuilder(this, true).type(type).build();
127 }
128
129
130
131
132
133
134 @Nonnull
135 public ToolchainModel withProvides(Map<String, String> provides) {
136 return newBuilder(this, true).provides(provides).build();
137 }
138
139
140
141
142
143
144 @Nonnull
145 public ToolchainModel withConfiguration(XmlNode configuration) {
146 return newBuilder(this, true).configuration(configuration).build();
147 }
148
149
150
151
152
153
154
155
156 @Nonnull
157 public static ToolchainModel newInstance() {
158 return newInstance(true);
159 }
160
161
162
163
164
165
166
167
168 @Nonnull
169 public static ToolchainModel newInstance(boolean withDefaults) {
170 return newBuilder(withDefaults).build();
171 }
172
173
174
175
176
177
178
179
180 @Nonnull
181 public static Builder newBuilder() {
182 return newBuilder(true);
183 }
184
185
186
187
188
189
190
191 @Nonnull
192 public static Builder newBuilder(boolean withDefaults) {
193 return new Builder(withDefaults);
194 }
195
196
197
198
199
200
201
202
203 @Nonnull
204 public static Builder newBuilder(ToolchainModel from) {
205 return newBuilder(from, false);
206 }
207
208
209
210
211
212
213
214
215 @Nonnull
216 public static Builder newBuilder(ToolchainModel from, boolean forceCopy) {
217 return new Builder(from, forceCopy);
218 }
219
220
221
222
223
224
225 @NotThreadSafe
226 public static class Builder
227 extends TrackableBase.Builder
228 {
229 ToolchainModel base;
230 String type;
231 Map<String, String> provides;
232 XmlNode configuration;
233
234 Builder(boolean withDefaults) {
235 super(withDefaults);
236 if (withDefaults) {
237 }
238 }
239
240 Builder(ToolchainModel base, boolean forceCopy) {
241 super(base, forceCopy);
242 if (forceCopy) {
243 this.type = base.type;
244 this.provides = base.provides;
245 this.configuration = base.configuration;
246 } else {
247 this.base = base;
248 }
249 }
250
251 @Nonnull
252 public Builder type(String type) {
253 this.type = type;
254 return this;
255 }
256
257 @Nonnull
258 public Builder provides(Map<String, String> provides) {
259 this.provides = provides;
260 return this;
261 }
262
263 @Nonnull
264 public Builder configuration(XmlNode configuration) {
265 this.configuration = configuration;
266 return this;
267 }
268
269
270 @Nonnull
271 public ToolchainModel build() {
272 if (base != null
273 && (type == null || type == base.type)
274 && (provides == null || provides == base.provides)
275 && (configuration == null || configuration == base.configuration)
276 ) {
277 return base;
278 }
279 return new ToolchainModel(
280 type != null ? type : (base != null ? base.type : null),
281 provides != null ? provides : (base != null ? base.provides : null),
282 configuration != null ? configuration : (base != null ? base.configuration : null)
283 );
284 }
285 }
286
287
288
289
290
291
292
293
294 public int hashCode()
295 {
296 int result = 17;
297
298 result = 37 * result + ( getType() != null ? getType().hashCode() : 0 );
299 result = 37 * result + ( getProvides() != null ? getProvides().hashCode() : 0 );
300
301 return result;
302 }
303
304
305
306
307
308
309
310 public boolean equals( Object other )
311 {
312 if ( this == other )
313 {
314 return true;
315 }
316
317 if ( !( other instanceof ToolchainModel ) )
318 {
319 return false;
320 }
321
322 ToolchainModel that = (ToolchainModel) other;
323 boolean result = true;
324
325 result = result && ( getType() == null ? that.getType() == null : getType().equals( that.getType() ) );
326 result = result && ( getProvides() == null ? that.getProvides() == null : getProvides().equals( that.getProvides() ) );
327
328 return result;
329 }
330
331
332 }