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.Objects;
15  import java.util.Optional;
16  import java.util.Set;
17  import java.util.stream.Collectors;
18  import java.util.stream.Stream;
19  import org.apache.maven.api.annotations.Experimental;
20  import org.apache.maven.api.annotations.Generated;
21  import org.apache.maven.api.annotations.Immutable;
22  import org.apache.maven.api.annotations.Nonnull;
23  import org.apache.maven.api.annotations.NotThreadSafe;
24  import org.apache.maven.api.annotations.ThreadSafe;
25  import org.apache.maven.api.xml.XmlNode;
26  
27  /**
28   * Represents a set of reports and configuration to be used to generate them.
29   */
30  @Experimental
31  @Generated @ThreadSafe @Immutable
32  public class ReportSet
33      extends ConfigurationContainer
34      implements Serializable, InputLocationTracker
35  {
36      /**
37       * The unique id for this report set, to be used during POM inheritance and profile injection
38       * for merging of report sets.
39       */
40      final String id;
41      /**
42       * The list of reports from this plugin which should be generated from this set.
43       */
44      final List<String> reports;
45  
46      /**
47        * Constructor for this class, to be called from its subclasses and {@link Builder}.
48        * @see Builder#build()
49        */
50      protected ReportSet(Builder builder) {
51          super(builder);
52          this.id = builder.id != null ? builder.id : (builder.base != null ? builder.base.id : null);
53          this.reports = ImmutableCollections.copy(builder.reports != null ? builder.reports : (builder.base != null ? builder.base.reports : null));
54      }
55  
56      /**
57       * The unique id for this report set, to be used during POM inheritance and profile injection
58       * for merging of report sets.
59       *
60       * @return a {@code String}
61       */
62      public String getId() {
63          return this.id;
64      }
65  
66      /**
67       * The list of reports from this plugin which should be generated from this set.
68       *
69       * @return a {@code List<String>}
70       */
71      @Nonnull
72      public List<String> getReports() {
73          return this.reports;
74      }
75  
76      /**
77       * Creates a new builder with this object as the basis.
78       *
79       * @return a {@code Builder}
80       */
81      @Nonnull
82      public Builder with() {
83          return newBuilder(this);
84      }
85      /**
86       * Creates a new {@code ReportSet} instance using the specified inherited.
87       *
88       * @param inherited the new {@code String} to use
89       * @return a {@code ReportSet} with the specified inherited
90       */
91      @Nonnull
92      public ReportSet withInherited(String inherited) {
93          return newBuilder(this, true).inherited(inherited).build();
94      }
95      /**
96       * Creates a new {@code ReportSet} instance using the specified configuration.
97       *
98       * @param configuration the new {@code XmlNode} to use
99       * @return a {@code ReportSet} with the specified configuration
100      */
101     @Nonnull
102     public ReportSet withConfiguration(XmlNode configuration) {
103         return newBuilder(this, true).configuration(configuration).build();
104     }
105     /**
106      * Creates a new {@code ReportSet} instance using the specified id.
107      *
108      * @param id the new {@code String} to use
109      * @return a {@code ReportSet} with the specified id
110      */
111     @Nonnull
112     public ReportSet withId(String id) {
113         return newBuilder(this, true).id(id).build();
114     }
115     /**
116      * Creates a new {@code ReportSet} instance using the specified reports.
117      *
118      * @param reports the new {@code Collection<String>} to use
119      * @return a {@code ReportSet} with the specified reports
120      */
121     @Nonnull
122     public ReportSet withReports(Collection<String> reports) {
123         return newBuilder(this, true).reports(reports).build();
124     }
125 
126     /**
127      * Creates a new {@code ReportSet} instance.
128      * Equivalent to {@code newInstance(true)}.
129      * @see #newInstance(boolean)
130      *
131      * @return a new {@code ReportSet}
132      */
133     @Nonnull
134     public static ReportSet newInstance() {
135         return newInstance(true);
136     }
137 
138     /**
139      * Creates a new {@code ReportSet} instance using default values or not.
140      * Equivalent to {@code newBuilder(withDefaults).build()}.
141      *
142      * @param withDefaults the boolean indicating whether default values should be used
143      * @return a new {@code ReportSet}
144      */
145     @Nonnull
146     public static ReportSet newInstance(boolean withDefaults) {
147         return newBuilder(withDefaults).build();
148     }
149 
150     /**
151      * Creates a new {@code ReportSet} builder instance.
152      * Equivalent to {@code newBuilder(true)}.
153      * @see #newBuilder(boolean)
154      *
155      * @return a new {@code Builder}
156      */
157     @Nonnull
158     public static Builder newBuilder() {
159         return newBuilder(true);
160     }
161 
162     /**
163      * Creates a new {@code ReportSet} builder instance using default values or not.
164      *
165      * @param withDefaults the boolean indicating whether default values should be used
166      * @return a new {@code Builder}
167      */
168     @Nonnull
169     public static Builder newBuilder(boolean withDefaults) {
170         return new Builder(withDefaults);
171     }
172 
173     /**
174      * Creates a new {@code ReportSet} builder instance using the specified object as a basis.
175      * Equivalent to {@code newBuilder(from, false)}.
176      *
177      * @param from the {@code ReportSet} instance to use as a basis
178      * @return a new {@code Builder}
179      */
180     @Nonnull
181     public static Builder newBuilder(ReportSet from) {
182         return newBuilder(from, false);
183     }
184 
185     /**
186      * Creates a new {@code ReportSet} builder instance using the specified object as a basis.
187      *
188      * @param from the {@code ReportSet} instance to use as a basis
189      * @param forceCopy the boolean indicating if a copy should be forced
190      * @return a new {@code Builder}
191      */
192     @Nonnull
193     public static Builder newBuilder(ReportSet from, boolean forceCopy) {
194         return new Builder(from, forceCopy);
195     }
196 
197     /**
198      * Builder class used to create ReportSet instances.
199      * @see #with()
200      * @see #newBuilder()
201      */
202     @NotThreadSafe
203     public static class Builder
204         extends ConfigurationContainer.Builder
205     {
206         ReportSet base;
207         String id;
208         Collection<String> reports;
209 
210         protected Builder(boolean withDefaults) {
211             super(withDefaults);
212             if (withDefaults) {
213                 this.id = "default";
214             }
215         }
216 
217         protected Builder(ReportSet base, boolean forceCopy) {
218             super(base, forceCopy);
219             if (forceCopy) {
220                 this.id = base.id;
221                 this.reports = base.reports;
222                 this.locations = base.locations;
223                 this.importedFrom = base.importedFrom;
224             } else {
225                 this.base = base;
226             }
227         }
228 
229         @Nonnull
230         public Builder inherited(String inherited) {
231             this.inherited = inherited;
232             return this;
233         }
234 
235         @Nonnull
236         public Builder configuration(XmlNode configuration) {
237             this.configuration = configuration;
238             return this;
239         }
240 
241         @Nonnull
242         public Builder id(String id) {
243             this.id = id;
244             return this;
245         }
246 
247         @Nonnull
248         public Builder reports(Collection<String> reports) {
249             this.reports = reports;
250             return this;
251         }
252 
253 
254         @Nonnull
255         public Builder location(Object key, InputLocation location) {
256             if (location != null) {
257                 if (!(this.locations instanceof HashMap)) {
258                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
259                 }
260                 this.locations.put(key, location);
261             }
262             return this;
263         }
264 
265         @Nonnull
266         public Builder importedFrom(InputLocation importedFrom) {
267             this.importedFrom = importedFrom;
268             return this;
269         }
270 
271         @Nonnull
272         public ReportSet build() {
273             // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
274             if (base != null
275                     && (inherited == null || inherited == base.inherited)
276                     && (configuration == null || configuration == base.configuration)
277                     && (id == null || id == base.id)
278                     && (reports == null || reports == base.reports)
279             ) {
280                 return base;
281             }
282             return new ReportSet(this);
283         }
284 
285     }
286 
287 
288             
289     @Override
290     public String toString() {
291         return getId();
292     }
293             
294           
295 }