View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
3   // ==============================================================
4   package org.apache.maven.api.model;
5   
6   import java.io.Serializable;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import org.apache.maven.api.annotations.Experimental;
14  import org.apache.maven.api.annotations.Generated;
15  import org.apache.maven.api.annotations.Immutable;
16  import org.apache.maven.api.annotations.Nonnull;
17  import org.apache.maven.api.annotations.NotThreadSafe;
18  import org.apache.maven.api.annotations.ThreadSafe;
19  
20  /**
21   * Information about one of the committers on this project.
22   */
23  @Experimental
24  @Generated @ThreadSafe @Immutable
25  public class Developer
26      extends Contributor
27      implements Serializable, InputLocationTracker
28  {
29      /**
30       * The unique ID of the developer in the SCM.
31       */
32      final String id;
33      /** Location of the xml element for the field id. */
34      final InputLocation idLocation;
35  
36      /**
37        * Constructor for this class, package protected.
38        * @see Builder#build()
39        */
40      Developer(
41          String name,
42          String email,
43          String url,
44          String organization,
45          String organizationUrl,
46          Collection<String> roles,
47          String timezone,
48          Map<String, String> properties,
49          String id,
50          Map<Object, InputLocation> locations,
51          InputLocation location,
52          InputLocation nameLocation,
53          InputLocation emailLocation,
54          InputLocation urlLocation,
55          InputLocation organizationLocation,
56          InputLocation organizationUrlLocation,
57          InputLocation rolesLocation,
58          InputLocation timezoneLocation,
59          InputLocation propertiesLocation,
60          InputLocation idLocation
61      )
62      {
63          super(
64              name,
65              email,
66              url,
67              organization,
68              organizationUrl,
69              roles,
70              timezone,
71              properties,
72              locations,
73              location,
74              nameLocation,
75              emailLocation,
76              urlLocation,
77              organizationLocation,
78              organizationUrlLocation,
79              rolesLocation,
80              timezoneLocation,
81              propertiesLocation
82          );
83          this.id = id;
84          this.idLocation = idLocation;
85      }
86  
87      /**
88       * The unique ID of the developer in the SCM.
89       *
90       * @return a {@code String}
91       */
92      public String getId()
93      {
94          return this.id;
95      }
96  
97      /**
98       * Gets the location of the specified field in the input source.
99       */
100     public InputLocation getLocation( Object key )
101     {
102         if ( key instanceof String )
103         {
104             switch ( ( String ) key )
105             {
106                 case "id":
107                     return idLocation;
108             }
109         }
110         return super.getLocation( key );
111     }
112 
113     /**
114      * Creates a new builder with this object as the basis.
115      *
116      * @return a {@code Builder}
117      */
118     @Nonnull
119     public Builder with()
120     {
121         return newBuilder( this );
122     }
123     /**
124      * Creates a new {@code Developer} instance using the specified name.
125      *
126      * @param name the new {@code String} to use
127      * @return a {@code Developer} with the specified name
128      */
129     @Nonnull
130     public Developer withName( String name )
131     {
132         return with().name( name ).build();
133     }
134     /**
135      * Creates a new {@code Developer} instance using the specified email.
136      *
137      * @param email the new {@code String} to use
138      * @return a {@code Developer} with the specified email
139      */
140     @Nonnull
141     public Developer withEmail( String email )
142     {
143         return with().email( email ).build();
144     }
145     /**
146      * Creates a new {@code Developer} instance using the specified url.
147      *
148      * @param url the new {@code String} to use
149      * @return a {@code Developer} with the specified url
150      */
151     @Nonnull
152     public Developer withUrl( String url )
153     {
154         return with().url( url ).build();
155     }
156     /**
157      * Creates a new {@code Developer} instance using the specified organization.
158      *
159      * @param organization the new {@code String} to use
160      * @return a {@code Developer} with the specified organization
161      */
162     @Nonnull
163     public Developer withOrganization( String organization )
164     {
165         return with().organization( organization ).build();
166     }
167     /**
168      * Creates a new {@code Developer} instance using the specified organizationUrl.
169      *
170      * @param organizationUrl the new {@code String} to use
171      * @return a {@code Developer} with the specified organizationUrl
172      */
173     @Nonnull
174     public Developer withOrganizationUrl( String organizationUrl )
175     {
176         return with().organizationUrl( organizationUrl ).build();
177     }
178     /**
179      * Creates a new {@code Developer} instance using the specified roles.
180      *
181      * @param roles the new {@code Collection<String>} to use
182      * @return a {@code Developer} with the specified roles
183      */
184     @Nonnull
185     public Developer withRoles( Collection<String> roles )
186     {
187         return with().roles( roles ).build();
188     }
189     /**
190      * Creates a new {@code Developer} instance using the specified timezone.
191      *
192      * @param timezone the new {@code String} to use
193      * @return a {@code Developer} with the specified timezone
194      */
195     @Nonnull
196     public Developer withTimezone( String timezone )
197     {
198         return with().timezone( timezone ).build();
199     }
200     /**
201      * Creates a new {@code Developer} instance using the specified properties.
202      *
203      * @param properties the new {@code Map<String, String>} to use
204      * @return a {@code Developer} with the specified properties
205      */
206     @Nonnull
207     public Developer withProperties( Map<String, String> properties )
208     {
209         return with().properties( properties ).build();
210     }
211     /**
212      * Creates a new {@code Developer} instance using the specified id.
213      *
214      * @param id the new {@code String} to use
215      * @return a {@code Developer} with the specified id
216      */
217     @Nonnull
218     public Developer withId( String id )
219     {
220         return with().id( id ).build();
221     }
222 
223     /**
224      * Creates a new {@code Developer} instance.
225      * Equivalent to {@code newInstance( true )}.
226      * @see #newInstance(boolean)
227      *
228      * @return a new {@code Developer}
229      */
230     @Nonnull
231     public static Developer newInstance()
232     {
233         return newInstance( true );
234     }
235 
236     /**
237      * Creates a new {@code Developer} instance using default values or not.
238      * Equivalent to {@code newBuilder( withDefaults ).build()}.
239      *
240      * @param withDefaults the boolean indicating whether default values should be used
241      * @return a new {@code Developer}
242      */
243     @Nonnull
244     public static Developer newInstance( boolean withDefaults )
245     {
246         return newBuilder( withDefaults ).build();
247     }
248 
249     /**
250      * Creates a new {@code Developer} builder instance.
251      * Equivalent to {@code newBuilder( true )}.
252      * @see #newBuilder(boolean)
253      *
254      * @return a new {@code Builder}
255      */
256     @Nonnull
257     public static Builder newBuilder()
258     {
259         return newBuilder( true );
260     }
261 
262     /**
263      * Creates a new {@code Developer} builder instance using default values or not.
264      *
265      * @param withDefaults the boolean indicating whether default values should be used
266      * @return a new {@code Builder}
267      */
268     @Nonnull
269     public static Builder newBuilder( boolean withDefaults )
270     {
271         return new Builder( withDefaults );
272     }
273 
274     /**
275      * Creates a new {@code Developer} builder instance using the specified object as a basis.
276      * Equivalent to {@code newBuilder( from, false )}.
277      *
278      * @param from the {@code Developer} instance to use as a basis
279      * @return a new {@code Builder}
280      */
281     @Nonnull
282     public static Builder newBuilder( Developer from )
283     {
284         return newBuilder( from, false );
285     }
286 
287     /**
288      * Creates a new {@code Developer} builder instance using the specified object as a basis.
289      *
290      * @param from the {@code Developer} instance to use as a basis
291      * @param forceCopy the boolean indicating if a copy should be forced
292      * @return a new {@code Builder}
293      */
294     @Nonnull
295     public static Builder newBuilder( Developer from, boolean forceCopy )
296     {
297         return new Builder( from, forceCopy );
298     }
299 
300     /**
301      * Builder class used to create Developer instances.
302      * @see #with()
303      * @see #newBuilder()
304      */
305     @NotThreadSafe
306     public static class Builder
307         extends Contributor.Builder
308     {
309         Developer base;
310         String id;
311 
312         Builder( boolean withDefaults )
313         {
314             super( withDefaults );
315             if ( withDefaults )
316             {
317             }
318         }
319 
320         Builder( Developer base, boolean forceCopy )
321         {
322             super( base, forceCopy );
323             if ( forceCopy )
324             {
325                 this.id = base.id;
326             }
327             else
328             {
329                 this.base = base;
330             }
331         }
332 
333         @Nonnull
334         public Builder name( String name )
335         {
336             this.name = name;
337             return this;
338         }
339 
340         @Nonnull
341         public Builder email( String email )
342         {
343             this.email = email;
344             return this;
345         }
346 
347         @Nonnull
348         public Builder url( String url )
349         {
350             this.url = url;
351             return this;
352         }
353 
354         @Nonnull
355         public Builder organization( String organization )
356         {
357             this.organization = organization;
358             return this;
359         }
360 
361         @Nonnull
362         public Builder organizationUrl( String organizationUrl )
363         {
364             this.organizationUrl = organizationUrl;
365             return this;
366         }
367 
368         @Nonnull
369         public Builder roles( Collection<String> roles )
370         {
371             this.roles = roles;
372             return this;
373         }
374 
375         @Nonnull
376         public Builder timezone( String timezone )
377         {
378             this.timezone = timezone;
379             return this;
380         }
381 
382         @Nonnull
383         public Builder properties( Map<String, String> properties )
384         {
385             this.properties = properties;
386             return this;
387         }
388 
389         @Nonnull
390         public Builder id( String id )
391         {
392             this.id = id;
393             return this;
394         }
395 
396 
397         @Nonnull
398         public Builder location( Object key, InputLocation location )
399         {
400             if ( location != null )
401             {
402                 if ( this.locations == null )
403                 {
404                     this.locations = new HashMap<>();
405                 }
406                 this.locations.put( key, location );
407             }
408             return this;
409         }
410 
411         @Nonnull
412         public Developer build()
413         {
414             if ( base != null
415                     && ( name == null || name == base.name )
416                     && ( email == null || email == base.email )
417                     && ( url == null || url == base.url )
418                     && ( organization == null || organization == base.organization )
419                     && ( organizationUrl == null || organizationUrl == base.organizationUrl )
420                     && ( roles == null || roles == base.roles )
421                     && ( timezone == null || timezone == base.timezone )
422                     && ( properties == null || properties == base.properties )
423                     && ( id == null || id == base.id )
424             )
425             {
426                 return base;
427             }
428             Map<Object, InputLocation> locations = null;
429             InputLocation location = null;
430             InputLocation nameLocation = null;
431             InputLocation emailLocation = null;
432             InputLocation urlLocation = null;
433             InputLocation organizationLocation = null;
434             InputLocation organizationUrlLocation = null;
435             InputLocation rolesLocation = null;
436             InputLocation timezoneLocation = null;
437             InputLocation propertiesLocation = null;
438             InputLocation idLocation = null;
439             if ( this.locations != null )
440             {
441                 locations = this.locations;
442                 location = locations.remove( "" );
443                 nameLocation = locations.remove( "name" );
444                 emailLocation = locations.remove( "email" );
445                 urlLocation = locations.remove( "url" );
446                 organizationLocation = locations.remove( "organization" );
447                 organizationUrlLocation = locations.remove( "organizationUrl" );
448                 rolesLocation = locations.remove( "roles" );
449                 timezoneLocation = locations.remove( "timezone" );
450                 propertiesLocation = locations.remove( "properties" );
451                 idLocation = locations.remove( "id" );
452             }
453             return new Developer(
454                 name != null ? name : ( base != null ? base.name : null ),
455                 email != null ? email : ( base != null ? base.email : null ),
456                 url != null ? url : ( base != null ? base.url : null ),
457                 organization != null ? organization : ( base != null ? base.organization : null ),
458                 organizationUrl != null ? organizationUrl : ( base != null ? base.organizationUrl : null ),
459                 roles != null ? roles : ( base != null ? base.roles : null ),
460                 timezone != null ? timezone : ( base != null ? base.timezone : null ),
461                 properties != null ? properties : ( base != null ? base.properties : null ),
462                 id != null ? id : ( base != null ? base.id : null ),
463                 locations != null ? locations : ( base != null ? base.locations : null ),
464                 location != null ? location : ( base != null ? base.location : null ),
465                 nameLocation != null ? nameLocation : ( base != null ? base.nameLocation : null ),
466                 emailLocation != null ? emailLocation : ( base != null ? base.emailLocation : null ),
467                 urlLocation != null ? urlLocation : ( base != null ? base.urlLocation : null ),
468                 organizationLocation != null ? organizationLocation : ( base != null ? base.organizationLocation : null ),
469                 organizationUrlLocation != null ? organizationUrlLocation : ( base != null ? base.organizationUrlLocation : null ),
470                 rolesLocation != null ? rolesLocation : ( base != null ? base.rolesLocation : null ),
471                 timezoneLocation != null ? timezoneLocation : ( base != null ? base.timezoneLocation : null ),
472                 propertiesLocation != null ? propertiesLocation : ( base != null ? base.propertiesLocation : null ),
473                 idLocation != null ? idLocation : ( base != null ? base.idLocation : null )
474             );
475         }
476     }
477 
478 }