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   * This element describes all of the mailing lists associated with a project. The
22   * auto-generated site references this information.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class MailingList
27      implements Serializable, InputLocationTracker
28  {
29      /**
30       * The name of the mailing list.
31       */
32      final String name;
33      /**
34       * The email address or link that can be used to subscribe to
35       * the mailing list.  If this is an email address, a
36       * {@code mailto:} link will automatically be created
37       * when the documentation is created.
38       */
39      final String subscribe;
40      /**
41       * The email address or link that can be used to unsubscribe to
42       * the mailing list.  If this is an email address, a
43       * {@code mailto:} link will automatically be created
44       * when the documentation is created.
45       */
46      final String unsubscribe;
47      /**
48       * The email address or link that can be used to post to
49       * the mailing list.  If this is an email address, a
50       * {@code mailto:} link will automatically be created
51       * when the documentation is created.
52       */
53      final String post;
54      /**
55       * The link to a URL where you can browse the mailing list archive.
56       */
57      final String archive;
58      /**
59       * The link to alternate URLs where you can browse the list archive.
60       */
61      final List<String> otherArchives;
62      /** Location of the xml element for this object. */
63      final InputLocation location;
64      /** Location of the xml element for the field name. */
65      final InputLocation nameLocation;
66      /** Location of the xml element for the field subscribe. */
67      final InputLocation subscribeLocation;
68      /** Location of the xml element for the field unsubscribe. */
69      final InputLocation unsubscribeLocation;
70      /** Location of the xml element for the field post. */
71      final InputLocation postLocation;
72      /** Location of the xml element for the field archive. */
73      final InputLocation archiveLocation;
74      /** Location of the xml element for the field otherArchives. */
75      final InputLocation otherArchivesLocation;
76      /** Other locations */
77      final Map<Object, InputLocation> locations;
78  
79      /**
80        * Constructor for this class, package protected.
81        * @see Builder#build()
82        */
83      MailingList(
84          String name,
85          String subscribe,
86          String unsubscribe,
87          String post,
88          String archive,
89          Collection<String> otherArchives,
90          Map<Object, InputLocation> locations,
91          InputLocation location,
92          InputLocation nameLocation,
93          InputLocation subscribeLocation,
94          InputLocation unsubscribeLocation,
95          InputLocation postLocation,
96          InputLocation archiveLocation,
97          InputLocation otherArchivesLocation
98      )
99      {
100         this.name = name;
101         this.subscribe = subscribe;
102         this.unsubscribe = unsubscribe;
103         this.post = post;
104         this.archive = archive;
105         this.otherArchives = ImmutableCollections.copy( otherArchives );
106         this.locations = ImmutableCollections.copy( locations );
107         this.location = location;
108         this.nameLocation = nameLocation;
109         this.subscribeLocation = subscribeLocation;
110         this.unsubscribeLocation = unsubscribeLocation;
111         this.postLocation = postLocation;
112         this.archiveLocation = archiveLocation;
113         this.otherArchivesLocation = otherArchivesLocation;
114     }
115 
116     /**
117      * The name of the mailing list.
118      *
119      * @return a {@code String}
120      */
121     public String getName()
122     {
123         return this.name;
124     }
125 
126     /**
127      * The email address or link that can be used to subscribe to
128      * the mailing list.  If this is an email address, a
129      * {@code mailto:} link will automatically be created
130      * when the documentation is created.
131      *
132      * @return a {@code String}
133      */
134     public String getSubscribe()
135     {
136         return this.subscribe;
137     }
138 
139     /**
140      * The email address or link that can be used to unsubscribe to
141      * the mailing list.  If this is an email address, a
142      * {@code mailto:} link will automatically be created
143      * when the documentation is created.
144      *
145      * @return a {@code String}
146      */
147     public String getUnsubscribe()
148     {
149         return this.unsubscribe;
150     }
151 
152     /**
153      * The email address or link that can be used to post to
154      * the mailing list.  If this is an email address, a
155      * {@code mailto:} link will automatically be created
156      * when the documentation is created.
157      *
158      * @return a {@code String}
159      */
160     public String getPost()
161     {
162         return this.post;
163     }
164 
165     /**
166      * The link to a URL where you can browse the mailing list archive.
167      *
168      * @return a {@code String}
169      */
170     public String getArchive()
171     {
172         return this.archive;
173     }
174 
175     /**
176      * The link to alternate URLs where you can browse the list archive.
177      *
178      * @return a {@code List<String>}
179      */
180     @Nonnull
181     public List<String> getOtherArchives()
182     {
183         return this.otherArchives;
184     }
185 
186     /**
187      * Gets the location of the specified field in the input source.
188      */
189     public InputLocation getLocation( Object key )
190     {
191         if ( key instanceof String )
192         {
193             switch ( ( String ) key )
194             {
195                 case "":
196                     return location;
197                 case "name":
198                     return nameLocation;
199                 case "subscribe":
200                     return subscribeLocation;
201                 case "unsubscribe":
202                     return unsubscribeLocation;
203                 case "post":
204                     return postLocation;
205                 case "archive":
206                     return archiveLocation;
207                 case "otherArchives":
208                     return otherArchivesLocation;
209             }
210         }
211         return locations != null ? locations.get( key ) : null;
212     }
213 
214     /**
215      * Creates a new builder with this object as the basis.
216      *
217      * @return a {@code Builder}
218      */
219     @Nonnull
220     public Builder with()
221     {
222         return newBuilder( this );
223     }
224     /**
225      * Creates a new {@code MailingList} instance using the specified name.
226      *
227      * @param name the new {@code String} to use
228      * @return a {@code MailingList} with the specified name
229      */
230     @Nonnull
231     public MailingList withName( String name )
232     {
233         return with().name( name ).build();
234     }
235     /**
236      * Creates a new {@code MailingList} instance using the specified subscribe.
237      *
238      * @param subscribe the new {@code String} to use
239      * @return a {@code MailingList} with the specified subscribe
240      */
241     @Nonnull
242     public MailingList withSubscribe( String subscribe )
243     {
244         return with().subscribe( subscribe ).build();
245     }
246     /**
247      * Creates a new {@code MailingList} instance using the specified unsubscribe.
248      *
249      * @param unsubscribe the new {@code String} to use
250      * @return a {@code MailingList} with the specified unsubscribe
251      */
252     @Nonnull
253     public MailingList withUnsubscribe( String unsubscribe )
254     {
255         return with().unsubscribe( unsubscribe ).build();
256     }
257     /**
258      * Creates a new {@code MailingList} instance using the specified post.
259      *
260      * @param post the new {@code String} to use
261      * @return a {@code MailingList} with the specified post
262      */
263     @Nonnull
264     public MailingList withPost( String post )
265     {
266         return with().post( post ).build();
267     }
268     /**
269      * Creates a new {@code MailingList} instance using the specified archive.
270      *
271      * @param archive the new {@code String} to use
272      * @return a {@code MailingList} with the specified archive
273      */
274     @Nonnull
275     public MailingList withArchive( String archive )
276     {
277         return with().archive( archive ).build();
278     }
279     /**
280      * Creates a new {@code MailingList} instance using the specified otherArchives.
281      *
282      * @param otherArchives the new {@code Collection<String>} to use
283      * @return a {@code MailingList} with the specified otherArchives
284      */
285     @Nonnull
286     public MailingList withOtherArchives( Collection<String> otherArchives )
287     {
288         return with().otherArchives( otherArchives ).build();
289     }
290 
291     /**
292      * Creates a new {@code MailingList} instance.
293      * Equivalent to {@code newInstance( true )}.
294      * @see #newInstance(boolean)
295      *
296      * @return a new {@code MailingList}
297      */
298     @Nonnull
299     public static MailingList newInstance()
300     {
301         return newInstance( true );
302     }
303 
304     /**
305      * Creates a new {@code MailingList} instance using default values or not.
306      * Equivalent to {@code newBuilder( withDefaults ).build()}.
307      *
308      * @param withDefaults the boolean indicating whether default values should be used
309      * @return a new {@code MailingList}
310      */
311     @Nonnull
312     public static MailingList newInstance( boolean withDefaults )
313     {
314         return newBuilder( withDefaults ).build();
315     }
316 
317     /**
318      * Creates a new {@code MailingList} builder instance.
319      * Equivalent to {@code newBuilder( true )}.
320      * @see #newBuilder(boolean)
321      *
322      * @return a new {@code Builder}
323      */
324     @Nonnull
325     public static Builder newBuilder()
326     {
327         return newBuilder( true );
328     }
329 
330     /**
331      * Creates a new {@code MailingList} builder instance using default values or not.
332      *
333      * @param withDefaults the boolean indicating whether default values should be used
334      * @return a new {@code Builder}
335      */
336     @Nonnull
337     public static Builder newBuilder( boolean withDefaults )
338     {
339         return new Builder( withDefaults );
340     }
341 
342     /**
343      * Creates a new {@code MailingList} builder instance using the specified object as a basis.
344      * Equivalent to {@code newBuilder( from, false )}.
345      *
346      * @param from the {@code MailingList} instance to use as a basis
347      * @return a new {@code Builder}
348      */
349     @Nonnull
350     public static Builder newBuilder( MailingList from )
351     {
352         return newBuilder( from, false );
353     }
354 
355     /**
356      * Creates a new {@code MailingList} builder instance using the specified object as a basis.
357      *
358      * @param from the {@code MailingList} instance to use as a basis
359      * @param forceCopy the boolean indicating if a copy should be forced
360      * @return a new {@code Builder}
361      */
362     @Nonnull
363     public static Builder newBuilder( MailingList from, boolean forceCopy )
364     {
365         return new Builder( from, forceCopy );
366     }
367 
368     /**
369      * Builder class used to create MailingList instances.
370      * @see #with()
371      * @see #newBuilder()
372      */
373     @NotThreadSafe
374     public static class Builder
375     {
376         MailingList base;
377         String name;
378         String subscribe;
379         String unsubscribe;
380         String post;
381         String archive;
382         Collection<String> otherArchives;
383         Map<Object, InputLocation> locations;
384 
385         Builder( boolean withDefaults )
386         {
387             if ( withDefaults )
388             {
389             }
390         }
391 
392         Builder( MailingList base, boolean forceCopy )
393         {
394             if ( forceCopy )
395             {
396                 this.name = base.name;
397                 this.subscribe = base.subscribe;
398                 this.unsubscribe = base.unsubscribe;
399                 this.post = base.post;
400                 this.archive = base.archive;
401                 this.otherArchives = base.otherArchives;
402             }
403             else
404             {
405                 this.base = base;
406             }
407         }
408 
409         @Nonnull
410         public Builder name( String name )
411         {
412             this.name = name;
413             return this;
414         }
415 
416         @Nonnull
417         public Builder subscribe( String subscribe )
418         {
419             this.subscribe = subscribe;
420             return this;
421         }
422 
423         @Nonnull
424         public Builder unsubscribe( String unsubscribe )
425         {
426             this.unsubscribe = unsubscribe;
427             return this;
428         }
429 
430         @Nonnull
431         public Builder post( String post )
432         {
433             this.post = post;
434             return this;
435         }
436 
437         @Nonnull
438         public Builder archive( String archive )
439         {
440             this.archive = archive;
441             return this;
442         }
443 
444         @Nonnull
445         public Builder otherArchives( Collection<String> otherArchives )
446         {
447             this.otherArchives = otherArchives;
448             return this;
449         }
450 
451 
452         @Nonnull
453         public Builder location( Object key, InputLocation location )
454         {
455             if ( location != null )
456             {
457                 if ( this.locations == null )
458                 {
459                     this.locations = new HashMap<>();
460                 }
461                 this.locations.put( key, location );
462             }
463             return this;
464         }
465 
466         @Nonnull
467         public MailingList build()
468         {
469             if ( base != null
470                     && ( name == null || name == base.name )
471                     && ( subscribe == null || subscribe == base.subscribe )
472                     && ( unsubscribe == null || unsubscribe == base.unsubscribe )
473                     && ( post == null || post == base.post )
474                     && ( archive == null || archive == base.archive )
475                     && ( otherArchives == null || otherArchives == base.otherArchives )
476             )
477             {
478                 return base;
479             }
480             Map<Object, InputLocation> locations = null;
481             InputLocation location = null;
482             InputLocation nameLocation = null;
483             InputLocation subscribeLocation = null;
484             InputLocation unsubscribeLocation = null;
485             InputLocation postLocation = null;
486             InputLocation archiveLocation = null;
487             InputLocation otherArchivesLocation = null;
488             if ( this.locations != null )
489             {
490                 locations = this.locations;
491                 location = locations.remove( "" );
492                 nameLocation = locations.remove( "name" );
493                 subscribeLocation = locations.remove( "subscribe" );
494                 unsubscribeLocation = locations.remove( "unsubscribe" );
495                 postLocation = locations.remove( "post" );
496                 archiveLocation = locations.remove( "archive" );
497                 otherArchivesLocation = locations.remove( "otherArchives" );
498             }
499             return new MailingList(
500                 name != null ? name : ( base != null ? base.name : null ),
501                 subscribe != null ? subscribe : ( base != null ? base.subscribe : null ),
502                 unsubscribe != null ? unsubscribe : ( base != null ? base.unsubscribe : null ),
503                 post != null ? post : ( base != null ? base.post : null ),
504                 archive != null ? archive : ( base != null ? base.archive : null ),
505                 otherArchives != null ? otherArchives : ( base != null ? base.otherArchives : null ),
506                 locations != null ? locations : ( base != null ? base.locations : null ),
507                 location != null ? location : ( base != null ? base.location : null ),
508                 nameLocation != null ? nameLocation : ( base != null ? base.nameLocation : null ),
509                 subscribeLocation != null ? subscribeLocation : ( base != null ? base.subscribeLocation : null ),
510                 unsubscribeLocation != null ? unsubscribeLocation : ( base != null ? base.unsubscribeLocation : null ),
511                 postLocation != null ? postLocation : ( base != null ? base.postLocation : null ),
512                 archiveLocation != null ? archiveLocation : ( base != null ? base.archiveLocation : null ),
513                 otherArchivesLocation != null ? otherArchivesLocation : ( base != null ? base.otherArchivesLocation : null )
514             );
515         }
516     }
517 
518 }