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      /** Locations */
64      final Map<Object, InputLocation> locations;
65  
66      /**
67        * Constructor for this class, package protected.
68        * @see Builder#build()
69        */
70      MailingList(
71          String name,
72          String subscribe,
73          String unsubscribe,
74          String post,
75          String archive,
76          Collection<String> otherArchives,
77          Map<Object, InputLocation> locations
78      ) {
79          this.name = name;
80          this.subscribe = subscribe;
81          this.unsubscribe = unsubscribe;
82          this.post = post;
83          this.archive = archive;
84          this.otherArchives = ImmutableCollections.copy(otherArchives);
85          this.locations = ImmutableCollections.copy(locations);
86      }
87  
88      /**
89       * The name of the mailing list.
90       *
91       * @return a {@code String}
92       */
93      public String getName() {
94          return this.name;
95      }
96  
97      /**
98       * The email address or link that can be used to subscribe to
99       * the mailing list.  If this is an email address, a
100      * {@code mailto:} link will automatically be created
101      * when the documentation is created.
102      *
103      * @return a {@code String}
104      */
105     public String getSubscribe() {
106         return this.subscribe;
107     }
108 
109     /**
110      * The email address or link that can be used to unsubscribe to
111      * the mailing list.  If this is an email address, a
112      * {@code mailto:} link will automatically be created
113      * when the documentation is created.
114      *
115      * @return a {@code String}
116      */
117     public String getUnsubscribe() {
118         return this.unsubscribe;
119     }
120 
121     /**
122      * The email address or link that can be used to post to
123      * the mailing list.  If this is an email address, a
124      * {@code mailto:} link will automatically be created
125      * when the documentation is created.
126      *
127      * @return a {@code String}
128      */
129     public String getPost() {
130         return this.post;
131     }
132 
133     /**
134      * The link to a URL where you can browse the mailing list archive.
135      *
136      * @return a {@code String}
137      */
138     public String getArchive() {
139         return this.archive;
140     }
141 
142     /**
143      * The link to alternate URLs where you can browse the list archive.
144      *
145      * @return a {@code List<String>}
146      */
147     @Nonnull
148     public List<String> getOtherArchives() {
149         return this.otherArchives;
150     }
151 
152     /**
153      * Gets the location of the specified field in the input source.
154      */
155     public InputLocation getLocation(Object key) {
156         return locations != null ? locations.get(key) : null;
157     }
158 
159     /**
160      * Creates a new builder with this object as the basis.
161      *
162      * @return a {@code Builder}
163      */
164     @Nonnull
165     public Builder with() {
166         return newBuilder(this);
167     }
168     /**
169      * Creates a new {@code MailingList} instance using the specified name.
170      *
171      * @param name the new {@code String} to use
172      * @return a {@code MailingList} with the specified name
173      */
174     @Nonnull
175     public MailingList withName(String name) {
176         return newBuilder(this, true).name(name).build();
177     }
178     /**
179      * Creates a new {@code MailingList} instance using the specified subscribe.
180      *
181      * @param subscribe the new {@code String} to use
182      * @return a {@code MailingList} with the specified subscribe
183      */
184     @Nonnull
185     public MailingList withSubscribe(String subscribe) {
186         return newBuilder(this, true).subscribe(subscribe).build();
187     }
188     /**
189      * Creates a new {@code MailingList} instance using the specified unsubscribe.
190      *
191      * @param unsubscribe the new {@code String} to use
192      * @return a {@code MailingList} with the specified unsubscribe
193      */
194     @Nonnull
195     public MailingList withUnsubscribe(String unsubscribe) {
196         return newBuilder(this, true).unsubscribe(unsubscribe).build();
197     }
198     /**
199      * Creates a new {@code MailingList} instance using the specified post.
200      *
201      * @param post the new {@code String} to use
202      * @return a {@code MailingList} with the specified post
203      */
204     @Nonnull
205     public MailingList withPost(String post) {
206         return newBuilder(this, true).post(post).build();
207     }
208     /**
209      * Creates a new {@code MailingList} instance using the specified archive.
210      *
211      * @param archive the new {@code String} to use
212      * @return a {@code MailingList} with the specified archive
213      */
214     @Nonnull
215     public MailingList withArchive(String archive) {
216         return newBuilder(this, true).archive(archive).build();
217     }
218     /**
219      * Creates a new {@code MailingList} instance using the specified otherArchives.
220      *
221      * @param otherArchives the new {@code Collection<String>} to use
222      * @return a {@code MailingList} with the specified otherArchives
223      */
224     @Nonnull
225     public MailingList withOtherArchives(Collection<String> otherArchives) {
226         return newBuilder(this, true).otherArchives(otherArchives).build();
227     }
228 
229     /**
230      * Creates a new {@code MailingList} instance.
231      * Equivalent to {@code newInstance(true)}.
232      * @see #newInstance(boolean)
233      *
234      * @return a new {@code MailingList}
235      */
236     @Nonnull
237     public static MailingList newInstance() {
238         return newInstance(true);
239     }
240 
241     /**
242      * Creates a new {@code MailingList} instance using default values or not.
243      * Equivalent to {@code newBuilder(withDefaults).build()}.
244      *
245      * @param withDefaults the boolean indicating whether default values should be used
246      * @return a new {@code MailingList}
247      */
248     @Nonnull
249     public static MailingList newInstance(boolean withDefaults) {
250         return newBuilder(withDefaults).build();
251     }
252 
253     /**
254      * Creates a new {@code MailingList} builder instance.
255      * Equivalent to {@code newBuilder(true)}.
256      * @see #newBuilder(boolean)
257      *
258      * @return a new {@code Builder}
259      */
260     @Nonnull
261     public static Builder newBuilder() {
262         return newBuilder(true);
263     }
264 
265     /**
266      * Creates a new {@code MailingList} builder instance using default values or not.
267      *
268      * @param withDefaults the boolean indicating whether default values should be used
269      * @return a new {@code Builder}
270      */
271     @Nonnull
272     public static Builder newBuilder(boolean withDefaults) {
273         return new Builder(withDefaults);
274     }
275 
276     /**
277      * Creates a new {@code MailingList} builder instance using the specified object as a basis.
278      * Equivalent to {@code newBuilder(from, false)}.
279      *
280      * @param from the {@code MailingList} instance to use as a basis
281      * @return a new {@code Builder}
282      */
283     @Nonnull
284     public static Builder newBuilder(MailingList from) {
285         return newBuilder(from, false);
286     }
287 
288     /**
289      * Creates a new {@code MailingList} builder instance using the specified object as a basis.
290      *
291      * @param from the {@code MailingList} instance to use as a basis
292      * @param forceCopy the boolean indicating if a copy should be forced
293      * @return a new {@code Builder}
294      */
295     @Nonnull
296     public static Builder newBuilder(MailingList from, boolean forceCopy) {
297         return new Builder(from, forceCopy);
298     }
299 
300     /**
301      * Builder class used to create MailingList instances.
302      * @see #with()
303      * @see #newBuilder()
304      */
305     @NotThreadSafe
306     public static class Builder
307     {
308         MailingList base;
309         String name;
310         String subscribe;
311         String unsubscribe;
312         String post;
313         String archive;
314         Collection<String> otherArchives;
315         Map<Object, InputLocation> locations;
316 
317         Builder(boolean withDefaults) {
318             if (withDefaults) {
319             }
320         }
321 
322         Builder(MailingList base, boolean forceCopy) {
323             if (forceCopy) {
324                 this.name = base.name;
325                 this.subscribe = base.subscribe;
326                 this.unsubscribe = base.unsubscribe;
327                 this.post = base.post;
328                 this.archive = base.archive;
329                 this.otherArchives = base.otherArchives;
330                 this.locations = base.locations;
331             } else {
332                 this.base = base;
333             }
334         }
335 
336         @Nonnull
337         public Builder name(String name) {
338             this.name = name;
339             return this;
340         }
341 
342         @Nonnull
343         public Builder subscribe(String subscribe) {
344             this.subscribe = subscribe;
345             return this;
346         }
347 
348         @Nonnull
349         public Builder unsubscribe(String unsubscribe) {
350             this.unsubscribe = unsubscribe;
351             return this;
352         }
353 
354         @Nonnull
355         public Builder post(String post) {
356             this.post = post;
357             return this;
358         }
359 
360         @Nonnull
361         public Builder archive(String archive) {
362             this.archive = archive;
363             return this;
364         }
365 
366         @Nonnull
367         public Builder otherArchives(Collection<String> otherArchives) {
368             this.otherArchives = otherArchives;
369             return this;
370         }
371 
372 
373         @Nonnull
374         public Builder location(Object key, InputLocation location) {
375             if (location != null) {
376                 if (!(this.locations instanceof HashMap)) {
377                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
378                 }
379                 this.locations.put(key, location);
380             }
381             return this;
382         }
383 
384         @Nonnull
385         public MailingList build() {
386             if (base != null
387                     && (name == null || name == base.name)
388                     && (subscribe == null || subscribe == base.subscribe)
389                     && (unsubscribe == null || unsubscribe == base.unsubscribe)
390                     && (post == null || post == base.post)
391                     && (archive == null || archive == base.archive)
392                     && (otherArchives == null || otherArchives == base.otherArchives)
393             ) {
394                 return base;
395             }
396             Map<Object, InputLocation> newlocs = this.locations != null ? this.locations : Collections.emptyMap();
397             Map<Object, InputLocation> oldlocs = this.base != null && this.base.locations != null ? this.base.locations : Collections.emptyMap();
398             Map<Object, InputLocation> locations = new HashMap<>();
399             locations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
400             locations.put("name", newlocs.containsKey("name") ? newlocs.get("name") : oldlocs.get("name"));
401             locations.put("subscribe", newlocs.containsKey("subscribe") ? newlocs.get("subscribe") : oldlocs.get("subscribe"));
402             locations.put("unsubscribe", newlocs.containsKey("unsubscribe") ? newlocs.get("unsubscribe") : oldlocs.get("unsubscribe"));
403             locations.put("post", newlocs.containsKey("post") ? newlocs.get("post") : oldlocs.get("post"));
404             locations.put("archive", newlocs.containsKey("archive") ? newlocs.get("archive") : oldlocs.get("archive"));
405             locations.put("otherArchives", newlocs.containsKey("otherArchives") ? newlocs.get("otherArchives") : oldlocs.get("otherArchives"));
406             return new MailingList(
407                 name != null ? name : (base != null ? base.name : null),
408                 subscribe != null ? subscribe : (base != null ? base.subscribe : null),
409                 unsubscribe != null ? unsubscribe : (base != null ? base.unsubscribe : null),
410                 post != null ? post : (base != null ? base.post : null),
411                 archive != null ? archive : (base != null ? base.archive : null),
412                 otherArchives != null ? otherArchives : (base != null ? base.otherArchives : null),
413                 locations
414             );
415         }
416     }
417 
418 
419             
420     /**
421      * @see java.lang.Object#toString()
422      */
423     public String toString()
424     {
425         return "MailingList {name=" + getName() + ", archive=" + getArchive() + "}";
426     }
427             
428           
429 }