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