1
2
3
4
5 package org.apache.maven.api.plugin.descriptor;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashMap;
10 import java.util.Map;
11 import java.util.Set;
12 import org.apache.maven.api.annotations.Experimental;
13 import org.apache.maven.api.annotations.Generated;
14 import org.apache.maven.api.annotations.Immutable;
15 import org.apache.maven.api.annotations.Nonnull;
16 import org.apache.maven.api.annotations.NotThreadSafe;
17 import org.apache.maven.api.annotations.ThreadSafe;
18
19
20
21
22 @Experimental
23 @Generated @ThreadSafe @Immutable
24 public class Parameter
25 implements Serializable
26 {
27
28
29
30
31 final String name;
32
33
34
35
36
37 final String alias;
38
39
40
41
42 final String type;
43
44
45
46
47 final boolean required;
48
49
50
51
52
53
54
55
56
57 final boolean editable;
58
59
60
61 final String description;
62
63
64
65 final String since;
66
67
68
69
70 final String deprecated;
71
72
73
74 final String expression;
75
76
77
78 final String defaultValue;
79
80
81
82
83
84 protected Parameter(Builder builder) {
85 this.name = builder.name != null ? builder.name : (builder.base != null ? builder.base.name : null);
86 this.alias = builder.alias != null ? builder.alias : (builder.base != null ? builder.base.alias : null);
87 this.type = builder.type != null ? builder.type : (builder.base != null ? builder.base.type : null);
88 this.required = builder.required != null ? builder.required : (builder.base != null ? builder.base.required : false);
89 this.editable = builder.editable != null ? builder.editable : (builder.base != null ? builder.base.editable : true);
90 this.description = builder.description != null ? builder.description : (builder.base != null ? builder.base.description : null);
91 this.since = builder.since != null ? builder.since : (builder.base != null ? builder.base.since : null);
92 this.deprecated = builder.deprecated != null ? builder.deprecated : (builder.base != null ? builder.base.deprecated : null);
93 this.expression = builder.expression != null ? builder.expression : (builder.base != null ? builder.base.expression : null);
94 this.defaultValue = builder.defaultValue != null ? builder.defaultValue : (builder.base != null ? builder.base.defaultValue : null);
95 }
96
97
98
99
100
101
102
103 public String getName() {
104 return this.name;
105 }
106
107
108
109
110
111
112
113
114 public String getAlias() {
115 return this.alias;
116 }
117
118
119
120
121
122
123
124 public String getType() {
125 return this.type;
126 }
127
128
129
130
131
132
133
134 public boolean isRequired() {
135 return this.required;
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149 public boolean isEditable() {
150 return this.editable;
151 }
152
153
154
155
156
157
158 public String getDescription() {
159 return this.description;
160 }
161
162
163
164
165
166
167 public String getSince() {
168 return this.since;
169 }
170
171
172
173
174
175
176
177 public String getDeprecated() {
178 return this.deprecated;
179 }
180
181
182
183
184
185
186 public String getExpression() {
187 return this.expression;
188 }
189
190
191
192
193
194
195 public String getDefaultValue() {
196 return this.defaultValue;
197 }
198
199
200
201
202
203
204 @Nonnull
205 public Builder with() {
206 return newBuilder(this);
207 }
208
209
210
211
212
213
214 @Nonnull
215 public Parameter withName(String name) {
216 return newBuilder(this, true).name(name).build();
217 }
218
219
220
221
222
223
224 @Nonnull
225 public Parameter withAlias(String alias) {
226 return newBuilder(this, true).alias(alias).build();
227 }
228
229
230
231
232
233
234 @Nonnull
235 public Parameter withType(String type) {
236 return newBuilder(this, true).type(type).build();
237 }
238
239
240
241
242
243
244 @Nonnull
245 public Parameter withRequired(boolean required) {
246 return newBuilder(this, true).required(required).build();
247 }
248
249
250
251
252
253
254 @Nonnull
255 public Parameter withEditable(boolean editable) {
256 return newBuilder(this, true).editable(editable).build();
257 }
258
259
260
261
262
263
264 @Nonnull
265 public Parameter withDescription(String description) {
266 return newBuilder(this, true).description(description).build();
267 }
268
269
270
271
272
273
274 @Nonnull
275 public Parameter withSince(String since) {
276 return newBuilder(this, true).since(since).build();
277 }
278
279
280
281
282
283
284 @Nonnull
285 public Parameter withDeprecated(String deprecated) {
286 return newBuilder(this, true).deprecated(deprecated).build();
287 }
288
289
290
291
292
293
294 @Nonnull
295 public Parameter withExpression(String expression) {
296 return newBuilder(this, true).expression(expression).build();
297 }
298
299
300
301
302
303
304 @Nonnull
305 public Parameter withDefaultValue(String defaultValue) {
306 return newBuilder(this, true).defaultValue(defaultValue).build();
307 }
308
309
310
311
312
313
314
315
316 @Nonnull
317 public static Parameter newInstance() {
318 return newInstance(true);
319 }
320
321
322
323
324
325
326
327
328 @Nonnull
329 public static Parameter newInstance(boolean withDefaults) {
330 return newBuilder(withDefaults).build();
331 }
332
333
334
335
336
337
338
339
340 @Nonnull
341 public static Builder newBuilder() {
342 return newBuilder(true);
343 }
344
345
346
347
348
349
350
351 @Nonnull
352 public static Builder newBuilder(boolean withDefaults) {
353 return new Builder(withDefaults);
354 }
355
356
357
358
359
360
361
362
363 @Nonnull
364 public static Builder newBuilder(Parameter from) {
365 return newBuilder(from, false);
366 }
367
368
369
370
371
372
373
374
375 @Nonnull
376 public static Builder newBuilder(Parameter from, boolean forceCopy) {
377 return new Builder(from, forceCopy);
378 }
379
380
381
382
383
384
385 @NotThreadSafe
386 public static class Builder
387 {
388 Parameter base;
389 String name;
390 String alias;
391 String type;
392 Boolean required;
393 Boolean editable;
394 String description;
395 String since;
396 String deprecated;
397 String expression;
398 String defaultValue;
399
400 protected Builder(boolean withDefaults) {
401 if (withDefaults) {
402 this.required = false;
403 this.editable = true;
404 }
405 }
406
407 protected Builder(Parameter base, boolean forceCopy) {
408 if (forceCopy) {
409 this.name = base.name;
410 this.alias = base.alias;
411 this.type = base.type;
412 this.required = base.required;
413 this.editable = base.editable;
414 this.description = base.description;
415 this.since = base.since;
416 this.deprecated = base.deprecated;
417 this.expression = base.expression;
418 this.defaultValue = base.defaultValue;
419 } else {
420 this.base = base;
421 }
422 }
423
424 @Nonnull
425 public Builder name(String name) {
426 this.name = name;
427 return this;
428 }
429
430 @Nonnull
431 public Builder alias(String alias) {
432 this.alias = alias;
433 return this;
434 }
435
436 @Nonnull
437 public Builder type(String type) {
438 this.type = type;
439 return this;
440 }
441
442 @Nonnull
443 public Builder required(boolean required) {
444 this.required = required;
445 return this;
446 }
447
448 @Nonnull
449 public Builder editable(boolean editable) {
450 this.editable = editable;
451 return this;
452 }
453
454 @Nonnull
455 public Builder description(String description) {
456 this.description = description;
457 return this;
458 }
459
460 @Nonnull
461 public Builder since(String since) {
462 this.since = since;
463 return this;
464 }
465
466 @Nonnull
467 public Builder deprecated(String deprecated) {
468 this.deprecated = deprecated;
469 return this;
470 }
471
472 @Nonnull
473 public Builder expression(String expression) {
474 this.expression = expression;
475 return this;
476 }
477
478 @Nonnull
479 public Builder defaultValue(String defaultValue) {
480 this.defaultValue = defaultValue;
481 return this;
482 }
483
484
485 @Nonnull
486 public Parameter build() {
487
488 if (base != null
489 && (name == null || name == base.name)
490 && (alias == null || alias == base.alias)
491 && (type == null || type == base.type)
492 && (required == null || required == base.required)
493 && (editable == null || editable == base.editable)
494 && (description == null || description == base.description)
495 && (since == null || since == base.since)
496 && (deprecated == null || deprecated == base.deprecated)
497 && (expression == null || expression == base.expression)
498 && (defaultValue == null || defaultValue == base.defaultValue)
499 ) {
500 return base;
501 }
502 return new Parameter(this);
503 }
504 }
505
506 }