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