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