View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
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   * Description of a person who has contributed to the project, but who does not have
22   * commit privileges. Usually, these contributions come in the form of patches submitted.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class Contributor
27      implements Serializable, InputLocationTracker
28  {
29      /**
30       * The full name of the contributor.
31       */
32      final String name;
33      /**
34       * The email address of the contributor.
35       */
36      final String email;
37      /**
38       * The URL for the homepage of the contributor.
39       */
40      final String url;
41      /**
42       * The organization to which the contributor belongs.
43       */
44      final String organization;
45      /**
46       * The URL of the organization.
47       */
48      final String organizationUrl;
49      /**
50       * The roles the contributor plays in the project. Each role is described by a
51       * {@code role} element, the body of which is a role name. This can also be used to
52       * describe the contribution.
53       */
54      final List<String> roles;
55      /**
56       * The timezone the contributor is in. Typically, this is a number in the range
57       * <a href="http://en.wikipedia.org/wiki/UTC%E2%88%9212:00">-12</a> to <a href="http://en.wikipedia.org/wiki/UTC%2B14:00">+14</a>
58       * or a valid time zone id like "America/Montreal" (UTC-05:00) or "Europe/Paris" (UTC+01:00).
59       */
60      final String timezone;
61      /**
62       * Properties about the contributor, such as an instant messenger handle.
63       */
64      final Map<String, String> properties;
65      /** Location of the xml element for this object. */
66      final InputLocation location;
67      /** Location of the xml element for the field name. */
68      final InputLocation nameLocation;
69      /** Location of the xml element for the field email. */
70      final InputLocation emailLocation;
71      /** Location of the xml element for the field url. */
72      final InputLocation urlLocation;
73      /** Location of the xml element for the field organization. */
74      final InputLocation organizationLocation;
75      /** Location of the xml element for the field organizationUrl. */
76      final InputLocation organizationUrlLocation;
77      /** Location of the xml element for the field roles. */
78      final InputLocation rolesLocation;
79      /** Location of the xml element for the field timezone. */
80      final InputLocation timezoneLocation;
81      /** Location of the xml element for the field properties. */
82      final InputLocation propertiesLocation;
83      /** Other locations */
84      final Map<Object, InputLocation> locations;
85  
86      /**
87        * Constructor for this class, package protected.
88        * @see Builder#build()
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      * The full name of the contributor.
133      *
134      * @return a {@code String}
135      */
136     public String getName()
137     {
138         return this.name;
139     }
140 
141     /**
142      * The email address of the contributor.
143      *
144      * @return a {@code String}
145      */
146     public String getEmail()
147     {
148         return this.email;
149     }
150 
151     /**
152      * The URL for the homepage of the contributor.
153      *
154      * @return a {@code String}
155      */
156     public String getUrl()
157     {
158         return this.url;
159     }
160 
161     /**
162      * The organization to which the contributor belongs.
163      *
164      * @return a {@code String}
165      */
166     public String getOrganization()
167     {
168         return this.organization;
169     }
170 
171     /**
172      * The URL of the organization.
173      *
174      * @return a {@code String}
175      */
176     public String getOrganizationUrl()
177     {
178         return this.organizationUrl;
179     }
180 
181     /**
182      * The roles the contributor plays in the project. Each role is described by a
183      * {@code role} element, the body of which is a role name. This can also be used to
184      * describe the contribution.
185      *
186      * @return a {@code List<String>}
187      */
188     @Nonnull
189     public List<String> getRoles()
190     {
191         return this.roles;
192     }
193 
194     /**
195      * The timezone the contributor is in. Typically, this is a number in the range
196      * <a href="http://en.wikipedia.org/wiki/UTC%E2%88%9212:00">-12</a> to <a href="http://en.wikipedia.org/wiki/UTC%2B14:00">+14</a>
197      * or a valid time zone id like "America/Montreal" (UTC-05:00) or "Europe/Paris" (UTC+01:00).
198      *
199      * @return a {@code String}
200      */
201     public String getTimezone()
202     {
203         return this.timezone;
204     }
205 
206     /**
207      * Properties about the contributor, such as an instant messenger handle.
208      *
209      * @return a {@code Map<String, String>}
210      */
211     @Nonnull
212     public Map<String, String> getProperties()
213     {
214         return this.properties;
215     }
216 
217     /**
218      * Gets the location of the specified field in the input source.
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      * Creates a new builder with this object as the basis.
251      *
252      * @return a {@code Builder}
253      */
254     @Nonnull
255     public Builder with()
256     {
257         return newBuilder( this );
258     }
259     /**
260      * Creates a new {@code Contributor} instance using the specified name.
261      *
262      * @param name the new {@code String} to use
263      * @return a {@code Contributor} with the specified name
264      */
265     @Nonnull
266     public Contributor withName( String name )
267     {
268         return with().name( name ).build();
269     }
270     /**
271      * Creates a new {@code Contributor} instance using the specified email.
272      *
273      * @param email the new {@code String} to use
274      * @return a {@code Contributor} with the specified email
275      */
276     @Nonnull
277     public Contributor withEmail( String email )
278     {
279         return with().email( email ).build();
280     }
281     /**
282      * Creates a new {@code Contributor} instance using the specified url.
283      *
284      * @param url the new {@code String} to use
285      * @return a {@code Contributor} with the specified url
286      */
287     @Nonnull
288     public Contributor withUrl( String url )
289     {
290         return with().url( url ).build();
291     }
292     /**
293      * Creates a new {@code Contributor} instance using the specified organization.
294      *
295      * @param organization the new {@code String} to use
296      * @return a {@code Contributor} with the specified organization
297      */
298     @Nonnull
299     public Contributor withOrganization( String organization )
300     {
301         return with().organization( organization ).build();
302     }
303     /**
304      * Creates a new {@code Contributor} instance using the specified organizationUrl.
305      *
306      * @param organizationUrl the new {@code String} to use
307      * @return a {@code Contributor} with the specified organizationUrl
308      */
309     @Nonnull
310     public Contributor withOrganizationUrl( String organizationUrl )
311     {
312         return with().organizationUrl( organizationUrl ).build();
313     }
314     /**
315      * Creates a new {@code Contributor} instance using the specified roles.
316      *
317      * @param roles the new {@code Collection<String>} to use
318      * @return a {@code Contributor} with the specified roles
319      */
320     @Nonnull
321     public Contributor withRoles( Collection<String> roles )
322     {
323         return with().roles( roles ).build();
324     }
325     /**
326      * Creates a new {@code Contributor} instance using the specified timezone.
327      *
328      * @param timezone the new {@code String} to use
329      * @return a {@code Contributor} with the specified timezone
330      */
331     @Nonnull
332     public Contributor withTimezone( String timezone )
333     {
334         return with().timezone( timezone ).build();
335     }
336     /**
337      * Creates a new {@code Contributor} instance using the specified properties.
338      *
339      * @param properties the new {@code Map<String, String>} to use
340      * @return a {@code Contributor} with the specified properties
341      */
342     @Nonnull
343     public Contributor withProperties( Map<String, String> properties )
344     {
345         return with().properties( properties ).build();
346     }
347 
348     /**
349      * Creates a new {@code Contributor} instance.
350      * Equivalent to {@code newInstance( true )}.
351      * @see #newInstance(boolean)
352      *
353      * @return a new {@code Contributor}
354      */
355     @Nonnull
356     public static Contributor newInstance()
357     {
358         return newInstance( true );
359     }
360 
361     /**
362      * Creates a new {@code Contributor} instance using default values or not.
363      * Equivalent to {@code newBuilder( withDefaults ).build()}.
364      *
365      * @param withDefaults the boolean indicating whether default values should be used
366      * @return a new {@code Contributor}
367      */
368     @Nonnull
369     public static Contributor newInstance( boolean withDefaults )
370     {
371         return newBuilder( withDefaults ).build();
372     }
373 
374     /**
375      * Creates a new {@code Contributor} builder instance.
376      * Equivalent to {@code newBuilder( true )}.
377      * @see #newBuilder(boolean)
378      *
379      * @return a new {@code Builder}
380      */
381     @Nonnull
382     public static Builder newBuilder()
383     {
384         return newBuilder( true );
385     }
386 
387     /**
388      * Creates a new {@code Contributor} builder instance using default values or not.
389      *
390      * @param withDefaults the boolean indicating whether default values should be used
391      * @return a new {@code Builder}
392      */
393     @Nonnull
394     public static Builder newBuilder( boolean withDefaults )
395     {
396         return new Builder( withDefaults );
397     }
398 
399     /**
400      * Creates a new {@code Contributor} builder instance using the specified object as a basis.
401      * Equivalent to {@code newBuilder( from, false )}.
402      *
403      * @param from the {@code Contributor} instance to use as a basis
404      * @return a new {@code Builder}
405      */
406     @Nonnull
407     public static Builder newBuilder( Contributor from )
408     {
409         return newBuilder( from, false );
410     }
411 
412     /**
413      * Creates a new {@code Contributor} builder instance using the specified object as a basis.
414      *
415      * @param from the {@code Contributor} instance to use as a basis
416      * @param forceCopy the boolean indicating if a copy should be forced
417      * @return a new {@code Builder}
418      */
419     @Nonnull
420     public static Builder newBuilder( Contributor from, boolean forceCopy )
421     {
422         return new Builder( from, forceCopy );
423     }
424 
425     /**
426      * Builder class used to create Contributor instances.
427      * @see #with()
428      * @see #newBuilder()
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 }