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      /** Locations */
67      final Map<Object, InputLocation> locations;
68  
69      /**
70        * Constructor for this class, package protected.
71        * @see Builder#build()
72        */
73      Contributor(
74          String name,
75          String email,
76          String url,
77          String organization,
78          String organizationUrl,
79          Collection<String> roles,
80          String timezone,
81          Map<String, String> properties,
82          Map<Object, InputLocation> locations
83      ) {
84          this.name = name;
85          this.email = email;
86          this.url = url;
87          this.organization = organization;
88          this.organizationUrl = organizationUrl;
89          this.roles = ImmutableCollections.copy(roles);
90          this.timezone = timezone;
91          this.properties = ImmutableCollections.copy(properties);
92          this.locations = ImmutableCollections.copy(locations);
93      }
94  
95      /**
96       * The full name of the contributor.
97       *
98       * @return a {@code String}
99       */
100     public String getName() {
101         return this.name;
102     }
103 
104     /**
105      * The email address of the contributor.
106      *
107      * @return a {@code String}
108      */
109     public String getEmail() {
110         return this.email;
111     }
112 
113     /**
114      * The URL for the homepage of the contributor.
115      *
116      * @return a {@code String}
117      */
118     public String getUrl() {
119         return this.url;
120     }
121 
122     /**
123      * The organization to which the contributor belongs.
124      *
125      * @return a {@code String}
126      */
127     public String getOrganization() {
128         return this.organization;
129     }
130 
131     /**
132      * The URL of the organization.
133      *
134      * @return a {@code String}
135      */
136     public String getOrganizationUrl() {
137         return this.organizationUrl;
138     }
139 
140     /**
141      * The roles the contributor plays in the project. Each role is described by a
142      * {@code role} element, the body of which is a role name. This can also be used to
143      * describe the contribution.
144      *
145      * @return a {@code List<String>}
146      */
147     @Nonnull
148     public List<String> getRoles() {
149         return this.roles;
150     }
151 
152     /**
153      * The timezone the contributor is in. Typically, this is a number in the range
154      * <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>
155      * or a valid time zone id like "America/Montreal" (UTC-05:00) or "Europe/Paris" (UTC+01:00).
156      *
157      * @return a {@code String}
158      */
159     public String getTimezone() {
160         return this.timezone;
161     }
162 
163     /**
164      * Properties about the contributor, such as an instant messenger handle.
165      *
166      * @return a {@code Map<String, String>}
167      */
168     @Nonnull
169     public Map<String, String> getProperties() {
170         return this.properties;
171     }
172 
173     /**
174      * Gets the location of the specified field in the input source.
175      */
176     public InputLocation getLocation(Object key) {
177         return locations != null ? locations.get(key) : null;
178     }
179 
180     /**
181      * Creates a new builder with this object as the basis.
182      *
183      * @return a {@code Builder}
184      */
185     @Nonnull
186     public Builder with() {
187         return newBuilder(this);
188     }
189     /**
190      * Creates a new {@code Contributor} instance using the specified name.
191      *
192      * @param name the new {@code String} to use
193      * @return a {@code Contributor} with the specified name
194      */
195     @Nonnull
196     public Contributor withName(String name) {
197         return newBuilder(this, true).name(name).build();
198     }
199     /**
200      * Creates a new {@code Contributor} instance using the specified email.
201      *
202      * @param email the new {@code String} to use
203      * @return a {@code Contributor} with the specified email
204      */
205     @Nonnull
206     public Contributor withEmail(String email) {
207         return newBuilder(this, true).email(email).build();
208     }
209     /**
210      * Creates a new {@code Contributor} instance using the specified url.
211      *
212      * @param url the new {@code String} to use
213      * @return a {@code Contributor} with the specified url
214      */
215     @Nonnull
216     public Contributor withUrl(String url) {
217         return newBuilder(this, true).url(url).build();
218     }
219     /**
220      * Creates a new {@code Contributor} instance using the specified organization.
221      *
222      * @param organization the new {@code String} to use
223      * @return a {@code Contributor} with the specified organization
224      */
225     @Nonnull
226     public Contributor withOrganization(String organization) {
227         return newBuilder(this, true).organization(organization).build();
228     }
229     /**
230      * Creates a new {@code Contributor} instance using the specified organizationUrl.
231      *
232      * @param organizationUrl the new {@code String} to use
233      * @return a {@code Contributor} with the specified organizationUrl
234      */
235     @Nonnull
236     public Contributor withOrganizationUrl(String organizationUrl) {
237         return newBuilder(this, true).organizationUrl(organizationUrl).build();
238     }
239     /**
240      * Creates a new {@code Contributor} instance using the specified roles.
241      *
242      * @param roles the new {@code Collection<String>} to use
243      * @return a {@code Contributor} with the specified roles
244      */
245     @Nonnull
246     public Contributor withRoles(Collection<String> roles) {
247         return newBuilder(this, true).roles(roles).build();
248     }
249     /**
250      * Creates a new {@code Contributor} instance using the specified timezone.
251      *
252      * @param timezone the new {@code String} to use
253      * @return a {@code Contributor} with the specified timezone
254      */
255     @Nonnull
256     public Contributor withTimezone(String timezone) {
257         return newBuilder(this, true).timezone(timezone).build();
258     }
259     /**
260      * Creates a new {@code Contributor} instance using the specified properties.
261      *
262      * @param properties the new {@code Map<String, String>} to use
263      * @return a {@code Contributor} with the specified properties
264      */
265     @Nonnull
266     public Contributor withProperties(Map<String, String> properties) {
267         return newBuilder(this, true).properties(properties).build();
268     }
269 
270     /**
271      * Creates a new {@code Contributor} instance.
272      * Equivalent to {@code newInstance(true)}.
273      * @see #newInstance(boolean)
274      *
275      * @return a new {@code Contributor}
276      */
277     @Nonnull
278     public static Contributor newInstance() {
279         return newInstance(true);
280     }
281 
282     /**
283      * Creates a new {@code Contributor} instance using default values or not.
284      * Equivalent to {@code newBuilder(withDefaults).build()}.
285      *
286      * @param withDefaults the boolean indicating whether default values should be used
287      * @return a new {@code Contributor}
288      */
289     @Nonnull
290     public static Contributor newInstance(boolean withDefaults) {
291         return newBuilder(withDefaults).build();
292     }
293 
294     /**
295      * Creates a new {@code Contributor} builder instance.
296      * Equivalent to {@code newBuilder(true)}.
297      * @see #newBuilder(boolean)
298      *
299      * @return a new {@code Builder}
300      */
301     @Nonnull
302     public static Builder newBuilder() {
303         return newBuilder(true);
304     }
305 
306     /**
307      * Creates a new {@code Contributor} builder instance using default values or not.
308      *
309      * @param withDefaults the boolean indicating whether default values should be used
310      * @return a new {@code Builder}
311      */
312     @Nonnull
313     public static Builder newBuilder(boolean withDefaults) {
314         return new Builder(withDefaults);
315     }
316 
317     /**
318      * Creates a new {@code Contributor} builder instance using the specified object as a basis.
319      * Equivalent to {@code newBuilder(from, false)}.
320      *
321      * @param from the {@code Contributor} instance to use as a basis
322      * @return a new {@code Builder}
323      */
324     @Nonnull
325     public static Builder newBuilder(Contributor from) {
326         return newBuilder(from, false);
327     }
328 
329     /**
330      * Creates a new {@code Contributor} builder instance using the specified object as a basis.
331      *
332      * @param from the {@code Contributor} instance to use as a basis
333      * @param forceCopy the boolean indicating if a copy should be forced
334      * @return a new {@code Builder}
335      */
336     @Nonnull
337     public static Builder newBuilder(Contributor from, boolean forceCopy) {
338         return new Builder(from, forceCopy);
339     }
340 
341     /**
342      * Builder class used to create Contributor instances.
343      * @see #with()
344      * @see #newBuilder()
345      */
346     @NotThreadSafe
347     public static class Builder
348     {
349         Contributor base;
350         String name;
351         String email;
352         String url;
353         String organization;
354         String organizationUrl;
355         Collection<String> roles;
356         String timezone;
357         Map<String, String> properties;
358         Map<Object, InputLocation> locations;
359 
360         Builder(boolean withDefaults) {
361             if (withDefaults) {
362             }
363         }
364 
365         Builder(Contributor base, boolean forceCopy) {
366             if (forceCopy) {
367                 this.name = base.name;
368                 this.email = base.email;
369                 this.url = base.url;
370                 this.organization = base.organization;
371                 this.organizationUrl = base.organizationUrl;
372                 this.roles = base.roles;
373                 this.timezone = base.timezone;
374                 this.properties = base.properties;
375                 this.locations = base.locations;
376             } else {
377                 this.base = base;
378             }
379         }
380 
381         @Nonnull
382         public Builder name(String name) {
383             this.name = name;
384             return this;
385         }
386 
387         @Nonnull
388         public Builder email(String email) {
389             this.email = email;
390             return this;
391         }
392 
393         @Nonnull
394         public Builder url(String url) {
395             this.url = url;
396             return this;
397         }
398 
399         @Nonnull
400         public Builder organization(String organization) {
401             this.organization = organization;
402             return this;
403         }
404 
405         @Nonnull
406         public Builder organizationUrl(String organizationUrl) {
407             this.organizationUrl = organizationUrl;
408             return this;
409         }
410 
411         @Nonnull
412         public Builder roles(Collection<String> roles) {
413             this.roles = roles;
414             return this;
415         }
416 
417         @Nonnull
418         public Builder timezone(String timezone) {
419             this.timezone = timezone;
420             return this;
421         }
422 
423         @Nonnull
424         public Builder properties(Map<String, String> properties) {
425             this.properties = properties;
426             return this;
427         }
428 
429 
430         @Nonnull
431         public Builder location(Object key, InputLocation location) {
432             if (location != null) {
433                 if (!(this.locations instanceof HashMap)) {
434                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
435                 }
436                 this.locations.put(key, location);
437             }
438             return this;
439         }
440 
441         @Nonnull
442         public Contributor build() {
443             if (base != null
444                     && (name == null || name == base.name)
445                     && (email == null || email == base.email)
446                     && (url == null || url == base.url)
447                     && (organization == null || organization == base.organization)
448                     && (organizationUrl == null || organizationUrl == base.organizationUrl)
449                     && (roles == null || roles == base.roles)
450                     && (timezone == null || timezone == base.timezone)
451                     && (properties == null || properties == base.properties)
452             ) {
453                 return base;
454             }
455             Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
456             Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
457             Map<Object, InputLocation> locations = new HashMap<>();
458             locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
459             locations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
460             locations.put("email", newlocs.containsKey("email") ? newlocs.get("email") : oldlocs.get("email"));
461             locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
462             locations.put("organization", newlocs.containsKey("organization") ? newlocs.get("organization") : oldlocs.get("organization"));
463             locations.put("organizationUrl", newlocs.containsKey("organizationUrl") ? newlocs.get("organizationUrl") : oldlocs.get("organizationUrl"));
464             locations.put("roles", newlocs.containsKey("roles") ? newlocs.get("roles") : oldlocs.get("roles"));
465             locations.put("timezone", newlocs.containsKey("timezone") ? newlocs.get("timezone") : oldlocs.get("timezone"));
466             locations.put("properties", newlocs.containsKey("properties") ? newlocs.get("properties") : oldlocs.get("properties"));
467             return new Contributor(
468                 name != null ? name : (base != null ? base.name : null),
469                 email != null ? email : (base != null ? base.email : null),
470                 url != null ? url : (base != null ? base.url : null),
471                 organization != null ? organization : (base != null ? base.organization : null),
472                 organizationUrl != null ? organizationUrl : (base != null ? base.organizationUrl : null),
473                 roles != null ? roles : (base != null ? base.roles : null),
474                 timezone != null ? timezone : (base != null ? base.timezone : null),
475                 properties != null ? properties : (base != null ? base.properties : null),
476                 locations
477             );
478         }
479     }
480 
481 
482             
483     /**
484      * @see java.lang.Object#toString()
485      */
486     public String toString()
487     {
488         return "Contributor {name=" + getName() + ", email=" + getEmail() + "}";
489     }
490             
491           
492 }