1
2
3
4 package org.apache.maven.api.model;
5
6 import java.io.Serializable;
7 import java.util.ArrayList;
8 import java.util.Collection;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import org.apache.maven.api.annotations.Experimental;
14 import org.apache.maven.api.annotations.Generated;
15 import org.apache.maven.api.annotations.Immutable;
16 import org.apache.maven.api.annotations.Nonnull;
17 import org.apache.maven.api.annotations.NotThreadSafe;
18 import org.apache.maven.api.annotations.ThreadSafe;
19
20
21
22
23
24 @Experimental
25 @Generated @ThreadSafe @Immutable
26 public class Contributor
27 implements Serializable, InputLocationTracker
28 {
29
30
31
32 final String name;
33
34
35
36 final String email;
37
38
39
40 final String url;
41
42
43
44 final String organization;
45
46
47
48 final String organizationUrl;
49
50
51
52
53
54 final List<String> roles;
55
56
57
58
59
60 final String timezone;
61
62
63
64 final Map<String, String> properties;
65
66 final InputLocation location;
67
68 final InputLocation nameLocation;
69
70 final InputLocation emailLocation;
71
72 final InputLocation urlLocation;
73
74 final InputLocation organizationLocation;
75
76 final InputLocation organizationUrlLocation;
77
78 final InputLocation rolesLocation;
79
80 final InputLocation timezoneLocation;
81
82 final InputLocation propertiesLocation;
83
84 final Map<Object, InputLocation> locations;
85
86
87
88
89
90 Contributor(
91 String name,
92 String email,
93 String url,
94 String organization,
95 String organizationUrl,
96 Collection<String> roles,
97 String timezone,
98 Map<String, String> properties,
99 Map<Object, InputLocation> locations,
100 InputLocation location,
101 InputLocation nameLocation,
102 InputLocation emailLocation,
103 InputLocation urlLocation,
104 InputLocation organizationLocation,
105 InputLocation organizationUrlLocation,
106 InputLocation rolesLocation,
107 InputLocation timezoneLocation,
108 InputLocation propertiesLocation
109 )
110 {
111 this.name = name;
112 this.email = email;
113 this.url = url;
114 this.organization = organization;
115 this.organizationUrl = organizationUrl;
116 this.roles = ImmutableCollections.copy( roles );
117 this.timezone = timezone;
118 this.properties = ImmutableCollections.copy( properties );
119 this.locations = ImmutableCollections.copy( locations );
120 this.location = location;
121 this.nameLocation = nameLocation;
122 this.emailLocation = emailLocation;
123 this.urlLocation = urlLocation;
124 this.organizationLocation = organizationLocation;
125 this.organizationUrlLocation = organizationUrlLocation;
126 this.rolesLocation = rolesLocation;
127 this.timezoneLocation = timezoneLocation;
128 this.propertiesLocation = propertiesLocation;
129 }
130
131
132
133
134
135
136 public String getName()
137 {
138 return this.name;
139 }
140
141
142
143
144
145
146 public String getEmail()
147 {
148 return this.email;
149 }
150
151
152
153
154
155
156 public String getUrl()
157 {
158 return this.url;
159 }
160
161
162
163
164
165
166 public String getOrganization()
167 {
168 return this.organization;
169 }
170
171
172
173
174
175
176 public String getOrganizationUrl()
177 {
178 return this.organizationUrl;
179 }
180
181
182
183
184
185
186
187
188 @Nonnull
189 public List<String> getRoles()
190 {
191 return this.roles;
192 }
193
194
195
196
197
198
199
200
201 public String getTimezone()
202 {
203 return this.timezone;
204 }
205
206
207
208
209
210
211 @Nonnull
212 public Map<String, String> getProperties()
213 {
214 return this.properties;
215 }
216
217
218
219
220 public InputLocation getLocation( Object key )
221 {
222 if ( key instanceof String )
223 {
224 switch ( ( String ) key )
225 {
226 case "":
227 return location;
228 case "name":
229 return nameLocation;
230 case "email":
231 return emailLocation;
232 case "url":
233 return urlLocation;
234 case "organization":
235 return organizationLocation;
236 case "organizationUrl":
237 return organizationUrlLocation;
238 case "roles":
239 return rolesLocation;
240 case "timezone":
241 return timezoneLocation;
242 case "properties":
243 return propertiesLocation;
244 }
245 }
246 return locations != null ? locations.get( key ) : null;
247 }
248
249
250
251
252
253
254 @Nonnull
255 public Builder with()
256 {
257 return newBuilder( this );
258 }
259
260
261
262
263
264
265 @Nonnull
266 public Contributor withName( String name )
267 {
268 return with().name( name ).build();
269 }
270
271
272
273
274
275
276 @Nonnull
277 public Contributor withEmail( String email )
278 {
279 return with().email( email ).build();
280 }
281
282
283
284
285
286
287 @Nonnull
288 public Contributor withUrl( String url )
289 {
290 return with().url( url ).build();
291 }
292
293
294
295
296
297
298 @Nonnull
299 public Contributor withOrganization( String organization )
300 {
301 return with().organization( organization ).build();
302 }
303
304
305
306
307
308
309 @Nonnull
310 public Contributor withOrganizationUrl( String organizationUrl )
311 {
312 return with().organizationUrl( organizationUrl ).build();
313 }
314
315
316
317
318
319
320 @Nonnull
321 public Contributor withRoles( Collection<String> roles )
322 {
323 return with().roles( roles ).build();
324 }
325
326
327
328
329
330
331 @Nonnull
332 public Contributor withTimezone( String timezone )
333 {
334 return with().timezone( timezone ).build();
335 }
336
337
338
339
340
341
342 @Nonnull
343 public Contributor withProperties( Map<String, String> properties )
344 {
345 return with().properties( properties ).build();
346 }
347
348
349
350
351
352
353
354
355 @Nonnull
356 public static Contributor newInstance()
357 {
358 return newInstance( true );
359 }
360
361
362
363
364
365
366
367
368 @Nonnull
369 public static Contributor newInstance( boolean withDefaults )
370 {
371 return newBuilder( withDefaults ).build();
372 }
373
374
375
376
377
378
379
380
381 @Nonnull
382 public static Builder newBuilder()
383 {
384 return newBuilder( true );
385 }
386
387
388
389
390
391
392
393 @Nonnull
394 public static Builder newBuilder( boolean withDefaults )
395 {
396 return new Builder( withDefaults );
397 }
398
399
400
401
402
403
404
405
406 @Nonnull
407 public static Builder newBuilder( Contributor from )
408 {
409 return newBuilder( from, false );
410 }
411
412
413
414
415
416
417
418
419 @Nonnull
420 public static Builder newBuilder( Contributor from, boolean forceCopy )
421 {
422 return new Builder( from, forceCopy );
423 }
424
425
426
427
428
429
430 @NotThreadSafe
431 public static class Builder
432 {
433 Contributor base;
434 String name;
435 String email;
436 String url;
437 String organization;
438 String organizationUrl;
439 Collection<String> roles;
440 String timezone;
441 Map<String, String> properties;
442 Map<Object, InputLocation> locations;
443
444 Builder( boolean withDefaults )
445 {
446 if ( withDefaults )
447 {
448 }
449 }
450
451 Builder( Contributor base, boolean forceCopy )
452 {
453 if ( forceCopy )
454 {
455 this.name = base.name;
456 this.email = base.email;
457 this.url = base.url;
458 this.organization = base.organization;
459 this.organizationUrl = base.organizationUrl;
460 this.roles = base.roles;
461 this.timezone = base.timezone;
462 this.properties = base.properties;
463 }
464 else
465 {
466 this.base = base;
467 }
468 }
469
470 @Nonnull
471 public Builder name( String name )
472 {
473 this.name = name;
474 return this;
475 }
476
477 @Nonnull
478 public Builder email( String email )
479 {
480 this.email = email;
481 return this;
482 }
483
484 @Nonnull
485 public Builder url( String url )
486 {
487 this.url = url;
488 return this;
489 }
490
491 @Nonnull
492 public Builder organization( String organization )
493 {
494 this.organization = organization;
495 return this;
496 }
497
498 @Nonnull
499 public Builder organizationUrl( String organizationUrl )
500 {
501 this.organizationUrl = organizationUrl;
502 return this;
503 }
504
505 @Nonnull
506 public Builder roles( Collection<String> roles )
507 {
508 this.roles = roles;
509 return this;
510 }
511
512 @Nonnull
513 public Builder timezone( String timezone )
514 {
515 this.timezone = timezone;
516 return this;
517 }
518
519 @Nonnull
520 public Builder properties( Map<String, String> properties )
521 {
522 this.properties = properties;
523 return this;
524 }
525
526
527 @Nonnull
528 public Builder location( Object key, InputLocation location )
529 {
530 if ( location != null )
531 {
532 if ( this.locations == null )
533 {
534 this.locations = new HashMap<>();
535 }
536 this.locations.put( key, location );
537 }
538 return this;
539 }
540
541 @Nonnull
542 public Contributor build()
543 {
544 if ( base != null
545 && ( name == null || name == base.name )
546 && ( email == null || email == base.email )
547 && ( url == null || url == base.url )
548 && ( organization == null || organization == base.organization )
549 && ( organizationUrl == null || organizationUrl == base.organizationUrl )
550 && ( roles == null || roles == base.roles )
551 && ( timezone == null || timezone == base.timezone )
552 && ( properties == null || properties == base.properties )
553 )
554 {
555 return base;
556 }
557 Map<Object, InputLocation> locations = null;
558 InputLocation location = null;
559 InputLocation nameLocation = null;
560 InputLocation emailLocation = null;
561 InputLocation urlLocation = null;
562 InputLocation organizationLocation = null;
563 InputLocation organizationUrlLocation = null;
564 InputLocation rolesLocation = null;
565 InputLocation timezoneLocation = null;
566 InputLocation propertiesLocation = null;
567 if ( this.locations != null )
568 {
569 locations = this.locations;
570 location = locations.remove( "" );
571 nameLocation = locations.remove( "name" );
572 emailLocation = locations.remove( "email" );
573 urlLocation = locations.remove( "url" );
574 organizationLocation = locations.remove( "organization" );
575 organizationUrlLocation = locations.remove( "organizationUrl" );
576 rolesLocation = locations.remove( "roles" );
577 timezoneLocation = locations.remove( "timezone" );
578 propertiesLocation = locations.remove( "properties" );
579 }
580 return new Contributor(
581 name != null ? name : ( base != null ? base.name : null ),
582 email != null ? email : ( base != null ? base.email : null ),
583 url != null ? url : ( base != null ? base.url : null ),
584 organization != null ? organization : ( base != null ? base.organization : null ),
585 organizationUrl != null ? organizationUrl : ( base != null ? base.organizationUrl : null ),
586 roles != null ? roles : ( base != null ? base.roles : null ),
587 timezone != null ? timezone : ( base != null ? base.timezone : null ),
588 properties != null ? properties : ( base != null ? base.properties : null ),
589 locations != null ? locations : ( base != null ? base.locations : null ),
590 location != null ? location : ( base != null ? base.location : null ),
591 nameLocation != null ? nameLocation : ( base != null ? base.nameLocation : null ),
592 emailLocation != null ? emailLocation : ( base != null ? base.emailLocation : null ),
593 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
594 organizationLocation != null ? organizationLocation : ( base != null ? base.organizationLocation : null ),
595 organizationUrlLocation != null ? organizationUrlLocation : ( base != null ? base.organizationUrlLocation : null ),
596 rolesLocation != null ? rolesLocation : ( base != null ? base.rolesLocation : null ),
597 timezoneLocation != null ? timezoneLocation : ( base != null ? base.timezoneLocation : null ),
598 propertiesLocation != null ? propertiesLocation : ( base != null ? base.propertiesLocation : null )
599 );
600 }
601 }
602
603 }