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   * Information about one of the committers on this project.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class Developer
27      extends Contributor
28      implements Serializable, InputLocationTracker
29  {
30      /**
31       * The unique ID of the developer in the SCM.
32       */
33      final String id;
34  
35      /**
36        * Constructor for this class, package protected.
37        * @see Builder#build()
38        */
39      Developer(
40          String name,
41          String email,
42          String url,
43          String organization,
44          String organizationUrl,
45          Collection<String> roles,
46          String timezone,
47          Map<String, String> properties,
48          String id,
49          Map<Object, InputLocation> locations
50      ) {
51          super(
52              name,
53              email,
54              url,
55              organization,
56              organizationUrl,
57              roles,
58              timezone,
59              properties,
60              locations
61          );
62          this.id = id;
63      }
64  
65      /**
66       * The unique ID of the developer in the SCM.
67       *
68       * @return a {@code String}
69       */
70      public String getId() {
71          return this.id;
72      }
73  
74      /**
75       * Creates a new builder with this object as the basis.
76       *
77       * @return a {@code Builder}
78       */
79      @Nonnull
80      public Builder with() {
81          return newBuilder(this);
82      }
83      /**
84       * Creates a new {@code Developer} instance using the specified name.
85       *
86       * @param name the new {@code String} to use
87       * @return a {@code Developer} with the specified name
88       */
89      @Nonnull
90      public Developer withName(String name) {
91          return newBuilder(this, true).name(name).build();
92      }
93      /**
94       * Creates a new {@code Developer} instance using the specified email.
95       *
96       * @param email the new {@code String} to use
97       * @return a {@code Developer} with the specified email
98       */
99      @Nonnull
100     public Developer withEmail(String email) {
101         return newBuilder(this, true).email(email).build();
102     }
103     /**
104      * Creates a new {@code Developer} instance using the specified url.
105      *
106      * @param url the new {@code String} to use
107      * @return a {@code Developer} with the specified url
108      */
109     @Nonnull
110     public Developer withUrl(String url) {
111         return newBuilder(this, true).url(url).build();
112     }
113     /**
114      * Creates a new {@code Developer} instance using the specified organization.
115      *
116      * @param organization the new {@code String} to use
117      * @return a {@code Developer} with the specified organization
118      */
119     @Nonnull
120     public Developer withOrganization(String organization) {
121         return newBuilder(this, true).organization(organization).build();
122     }
123     /**
124      * Creates a new {@code Developer} instance using the specified organizationUrl.
125      *
126      * @param organizationUrl the new {@code String} to use
127      * @return a {@code Developer} with the specified organizationUrl
128      */
129     @Nonnull
130     public Developer withOrganizationUrl(String organizationUrl) {
131         return newBuilder(this, true).organizationUrl(organizationUrl).build();
132     }
133     /**
134      * Creates a new {@code Developer} instance using the specified roles.
135      *
136      * @param roles the new {@code Collection<String>} to use
137      * @return a {@code Developer} with the specified roles
138      */
139     @Nonnull
140     public Developer withRoles(Collection<String> roles) {
141         return newBuilder(this, true).roles(roles).build();
142     }
143     /**
144      * Creates a new {@code Developer} instance using the specified timezone.
145      *
146      * @param timezone the new {@code String} to use
147      * @return a {@code Developer} with the specified timezone
148      */
149     @Nonnull
150     public Developer withTimezone(String timezone) {
151         return newBuilder(this, true).timezone(timezone).build();
152     }
153     /**
154      * Creates a new {@code Developer} instance using the specified properties.
155      *
156      * @param properties the new {@code Map<String, String>} to use
157      * @return a {@code Developer} with the specified properties
158      */
159     @Nonnull
160     public Developer withProperties(Map<String, String> properties) {
161         return newBuilder(this, true).properties(properties).build();
162     }
163     /**
164      * Creates a new {@code Developer} instance using the specified id.
165      *
166      * @param id the new {@code String} to use
167      * @return a {@code Developer} with the specified id
168      */
169     @Nonnull
170     public Developer withId(String id) {
171         return newBuilder(this, true).id(id).build();
172     }
173 
174     /**
175      * Creates a new {@code Developer} instance.
176      * Equivalent to {@code newInstance(true)}.
177      * @see #newInstance(boolean)
178      *
179      * @return a new {@code Developer}
180      */
181     @Nonnull
182     public static Developer newInstance() {
183         return newInstance(true);
184     }
185 
186     /**
187      * Creates a new {@code Developer} instance using default values or not.
188      * Equivalent to {@code newBuilder(withDefaults).build()}.
189      *
190      * @param withDefaults the boolean indicating whether default values should be used
191      * @return a new {@code Developer}
192      */
193     @Nonnull
194     public static Developer newInstance(boolean withDefaults) {
195         return newBuilder(withDefaults).build();
196     }
197 
198     /**
199      * Creates a new {@code Developer} builder instance.
200      * Equivalent to {@code newBuilder(true)}.
201      * @see #newBuilder(boolean)
202      *
203      * @return a new {@code Builder}
204      */
205     @Nonnull
206     public static Builder newBuilder() {
207         return newBuilder(true);
208     }
209 
210     /**
211      * Creates a new {@code Developer} builder instance using default values or not.
212      *
213      * @param withDefaults the boolean indicating whether default values should be used
214      * @return a new {@code Builder}
215      */
216     @Nonnull
217     public static Builder newBuilder(boolean withDefaults) {
218         return new Builder(withDefaults);
219     }
220 
221     /**
222      * Creates a new {@code Developer} builder instance using the specified object as a basis.
223      * Equivalent to {@code newBuilder(from, false)}.
224      *
225      * @param from the {@code Developer} instance to use as a basis
226      * @return a new {@code Builder}
227      */
228     @Nonnull
229     public static Builder newBuilder(Developer from) {
230         return newBuilder(from, false);
231     }
232 
233     /**
234      * Creates a new {@code Developer} builder instance using the specified object as a basis.
235      *
236      * @param from the {@code Developer} instance to use as a basis
237      * @param forceCopy the boolean indicating if a copy should be forced
238      * @return a new {@code Builder}
239      */
240     @Nonnull
241     public static Builder newBuilder(Developer from, boolean forceCopy) {
242         return new Builder(from, forceCopy);
243     }
244 
245     /**
246      * Builder class used to create Developer instances.
247      * @see #with()
248      * @see #newBuilder()
249      */
250     @NotThreadSafe
251     public static class Builder
252         extends Contributor.Builder
253     {
254         Developer base;
255         String id;
256 
257         Builder(boolean withDefaults) {
258             super(withDefaults);
259             if (withDefaults) {
260             }
261         }
262 
263         Builder(Developer base, boolean forceCopy) {
264             super(base, forceCopy);
265             if (forceCopy) {
266                 this.id = base.id;
267                 this.locations = base.locations;
268             } else {
269                 this.base = base;
270             }
271         }
272 
273         @Nonnull
274         public Builder name(String name) {
275             this.name = name;
276             return this;
277         }
278 
279         @Nonnull
280         public Builder email(String email) {
281             this.email = email;
282             return this;
283         }
284 
285         @Nonnull
286         public Builder url(String url) {
287             this.url = url;
288             return this;
289         }
290 
291         @Nonnull
292         public Builder organization(String organization) {
293             this.organization = organization;
294             return this;
295         }
296 
297         @Nonnull
298         public Builder organizationUrl(String organizationUrl) {
299             this.organizationUrl = organizationUrl;
300             return this;
301         }
302 
303         @Nonnull
304         public Builder roles(Collection<String> roles) {
305             this.roles = roles;
306             return this;
307         }
308 
309         @Nonnull
310         public Builder timezone(String timezone) {
311             this.timezone = timezone;
312             return this;
313         }
314 
315         @Nonnull
316         public Builder properties(Map<String, String> properties) {
317             this.properties = properties;
318             return this;
319         }
320 
321         @Nonnull
322         public Builder id(String id) {
323             this.id = id;
324             return this;
325         }
326 
327 
328         @Nonnull
329         public Builder location(Object key, InputLocation location) {
330             if (location != null) {
331                 if (!(this.locations instanceof HashMap)) {
332                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
333                 }
334                 this.locations.put(key, location);
335             }
336             return this;
337         }
338 
339         @Nonnull
340         public Developer build() {
341             if (base != null
342                     && (name == null || name == base.name)
343                     && (email == null || email == base.email)
344                     && (url == null || url == base.url)
345                     && (organization == null || organization == base.organization)
346                     && (organizationUrl == null || organizationUrl == base.organizationUrl)
347                     && (roles == null || roles == base.roles)
348                     && (timezone == null || timezone == base.timezone)
349                     && (properties == null || properties == base.properties)
350                     && (id == null || id == base.id)
351             ) {
352                 return base;
353             }
354             Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
355             Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
356             Map<Object, InputLocation> locations = new HashMap<>();
357             locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
358             locations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
359             locations.put("email", newlocs.containsKey("email") ? newlocs.get("email") : oldlocs.get("email"));
360             locations.put("url", newlocs.containsKey("url") ? newlocs.get("url") : oldlocs.get("url"));
361             locations.put("organization", newlocs.containsKey("organization") ? newlocs.get("organization") : oldlocs.get("organization"));
362             locations.put("organizationUrl", newlocs.containsKey("organizationUrl") ? newlocs.get("organizationUrl") : oldlocs.get("organizationUrl"));
363             locations.put("roles", newlocs.containsKey("roles") ? newlocs.get("roles") : oldlocs.get("roles"));
364             locations.put("timezone", newlocs.containsKey("timezone") ? newlocs.get("timezone") : oldlocs.get("timezone"));
365             locations.put("properties", newlocs.containsKey("properties") ? newlocs.get("properties") : oldlocs.get("properties"));
366             locations.put("id", newlocs.containsKey("id") ? newlocs.get("id") : oldlocs.get("id"));
367             return new Developer(
368                 name != null ? name : (base != null ? base.name : null),
369                 email != null ? email : (base != null ? base.email : null),
370                 url != null ? url : (base != null ? base.url : null),
371                 organization != null ? organization : (base != null ? base.organization : null),
372                 organizationUrl != null ? organizationUrl : (base != null ? base.organizationUrl : null),
373                 roles != null ? roles : (base != null ? base.roles : null),
374                 timezone != null ? timezone : (base != null ? base.timezone : null),
375                 properties != null ? properties : (base != null ? base.properties : null),
376                 id != null ? id : (base != null ? base.id : null),
377                 locations
378             );
379         }
380     }
381 
382 
383             
384     /**
385      * @see java.lang.Object#toString()
386      */
387     public String toString()
388     {
389         return "Developer {id=" + getId() + ", " + super.toString() + "}";
390     }
391             
392           
393 }