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