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