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