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