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