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   * Section for management of reports and their configuration.
24   */
25  @Experimental
26  @Generated @ThreadSafe @Immutable
27  public class Reporting
28      implements Serializable, InputLocationTracker
29  {
30      /**
31       * If true, then the default reports are not included in the site generation.
32       * This includes the reports in the "Project Info" menu. Note: While the type
33       * of this field is {@code String} for technical reasons, the semantic type is actually
34       * {@code Boolean}. Default value is {@code false}.
35       */
36      final String excludeDefaults;
37      /**
38       * Where to store all the generated reports. The default is
39       * {@code ${project.build.directory}/site}.
40       */
41      final String outputDirectory;
42      /**
43       * The reporting plugins to use and their configuration.
44       */
45      final List<ReportPlugin> plugins;
46      /** Locations (this potentially hides the same name field from the super class) */
47      final Map<Object, InputLocation> locations;
48      /** Location tracking */
49      final InputLocation importedFrom;
50  
51      /**
52        * Constructor for this class, to be called from its subclasses and {@link Builder}.
53        * @see Builder#build()
54        */
55      protected Reporting(Builder builder) {
56          this.excludeDefaults = builder.excludeDefaults != null ? builder.excludeDefaults : (builder.base != null ? builder.base.excludeDefaults : null);
57          this.outputDirectory = builder.outputDirectory != null ? builder.outputDirectory : (builder.base != null ? builder.base.outputDirectory : null);
58          this.plugins = ImmutableCollections.copy(builder.plugins != null ? builder.plugins : (builder.base != null ? builder.base.plugins : null));
59          Map<Object, InputLocation> newlocs = builder.locations != null ? builder.locations : Collections.emptyMap();
60          Map<Object, InputLocation> oldlocs = builder.base != null && builder.base.locations != null ? builder.base.locations : Collections.emptyMap();
61          Map<Object, InputLocation> mutableLocations = new HashMap<>();
62          this.importedFrom = builder.importedFrom;
63          mutableLocations.put("", newlocs.containsKey("") ? newlocs.get("") : oldlocs.get(""));
64          mutableLocations.put("excludeDefaults", newlocs.containsKey("excludeDefaults") ? newlocs.get("excludeDefaults") : oldlocs.get("excludeDefaults"));
65          mutableLocations.put("outputDirectory", newlocs.containsKey("outputDirectory") ? newlocs.get("outputDirectory") : oldlocs.get("outputDirectory"));
66          mutableLocations.put("plugins", newlocs.containsKey("plugins") ? newlocs.get("plugins") : oldlocs.get("plugins"));
67          this.locations = Collections.unmodifiableMap(mutableLocations);
68      }
69  
70      /**
71       * If true, then the default reports are not included in the site generation.
72       * This includes the reports in the "Project Info" menu. Note: While the type
73       * of this field is {@code String} for technical reasons, the semantic type is actually
74       * {@code Boolean}. Default value is {@code false}.
75       *
76       * @return a {@code String}
77       */
78      public String getExcludeDefaults() {
79          return this.excludeDefaults;
80      }
81  
82      /**
83       * Where to store all the generated reports. The default is
84       * {@code ${project.build.directory}/site}.
85       *
86       * @return a {@code String}
87       */
88      public String getOutputDirectory() {
89          return this.outputDirectory;
90      }
91  
92      /**
93       * The reporting plugins to use and their configuration.
94       *
95       * @return a {@code List<ReportPlugin>}
96       */
97      @Nonnull
98      public List<ReportPlugin> getPlugins() {
99          return this.plugins;
100     }
101 
102     /**
103      * Gets the location of the specified field in the input source.
104      */
105     public InputLocation getLocation(Object key) {
106         return locations != null ? locations.get(key) : null;
107     }
108 
109     /**
110     * Gets the keys of the locations of the input source.
111     */
112     public Set<Object> getLocationKeys() {
113         return locations != null ? locations.keySet() : null;
114     }
115 
116     /**
117      * Gets the input location that caused this model to be read.
118      */
119     public InputLocation getImportedFrom()
120     {
121         return importedFrom;
122     }
123 
124     /**
125      * Creates a new builder with this object as the basis.
126      *
127      * @return a {@code Builder}
128      */
129     @Nonnull
130     public Builder with() {
131         return newBuilder(this);
132     }
133     /**
134      * Creates a new {@code Reporting} instance using the specified excludeDefaults.
135      *
136      * @param excludeDefaults the new {@code String} to use
137      * @return a {@code Reporting} with the specified excludeDefaults
138      */
139     @Nonnull
140     public Reporting withExcludeDefaults(String excludeDefaults) {
141         return newBuilder(this, true).excludeDefaults(excludeDefaults).build();
142     }
143     /**
144      * Creates a new {@code Reporting} instance using the specified outputDirectory.
145      *
146      * @param outputDirectory the new {@code String} to use
147      * @return a {@code Reporting} with the specified outputDirectory
148      */
149     @Nonnull
150     public Reporting withOutputDirectory(String outputDirectory) {
151         return newBuilder(this, true).outputDirectory(outputDirectory).build();
152     }
153     /**
154      * Creates a new {@code Reporting} instance using the specified plugins.
155      *
156      * @param plugins the new {@code Collection<ReportPlugin>} to use
157      * @return a {@code Reporting} with the specified plugins
158      */
159     @Nonnull
160     public Reporting withPlugins(Collection<ReportPlugin> plugins) {
161         return newBuilder(this, true).plugins(plugins).build();
162     }
163 
164     /**
165      * Creates a new {@code Reporting} instance.
166      * Equivalent to {@code newInstance(true)}.
167      * @see #newInstance(boolean)
168      *
169      * @return a new {@code Reporting}
170      */
171     @Nonnull
172     public static Reporting newInstance() {
173         return newInstance(true);
174     }
175 
176     /**
177      * Creates a new {@code Reporting} instance using default values or not.
178      * Equivalent to {@code newBuilder(withDefaults).build()}.
179      *
180      * @param withDefaults the boolean indicating whether default values should be used
181      * @return a new {@code Reporting}
182      */
183     @Nonnull
184     public static Reporting newInstance(boolean withDefaults) {
185         return newBuilder(withDefaults).build();
186     }
187 
188     /**
189      * Creates a new {@code Reporting} builder instance.
190      * Equivalent to {@code newBuilder(true)}.
191      * @see #newBuilder(boolean)
192      *
193      * @return a new {@code Builder}
194      */
195     @Nonnull
196     public static Builder newBuilder() {
197         return newBuilder(true);
198     }
199 
200     /**
201      * Creates a new {@code Reporting} builder instance using default values or not.
202      *
203      * @param withDefaults the boolean indicating whether default values should be used
204      * @return a new {@code Builder}
205      */
206     @Nonnull
207     public static Builder newBuilder(boolean withDefaults) {
208         return new Builder(withDefaults);
209     }
210 
211     /**
212      * Creates a new {@code Reporting} builder instance using the specified object as a basis.
213      * Equivalent to {@code newBuilder(from, false)}.
214      *
215      * @param from the {@code Reporting} instance to use as a basis
216      * @return a new {@code Builder}
217      */
218     @Nonnull
219     public static Builder newBuilder(Reporting from) {
220         return newBuilder(from, false);
221     }
222 
223     /**
224      * Creates a new {@code Reporting} builder instance using the specified object as a basis.
225      *
226      * @param from the {@code Reporting} instance to use as a basis
227      * @param forceCopy the boolean indicating if a copy should be forced
228      * @return a new {@code Builder}
229      */
230     @Nonnull
231     public static Builder newBuilder(Reporting from, boolean forceCopy) {
232         return new Builder(from, forceCopy);
233     }
234 
235     /**
236      * Builder class used to create Reporting instances.
237      * @see #with()
238      * @see #newBuilder()
239      */
240     @NotThreadSafe
241     public static class Builder
242     {
243         Reporting base;
244         String excludeDefaults;
245         String outputDirectory;
246         Collection<ReportPlugin> plugins;
247         Map<Object, InputLocation> locations;
248         InputLocation importedFrom;
249 
250         protected Builder(boolean withDefaults) {
251             if (withDefaults) {
252             }
253         }
254 
255         protected Builder(Reporting base, boolean forceCopy) {
256             if (forceCopy) {
257                 this.excludeDefaults = base.excludeDefaults;
258                 this.outputDirectory = base.outputDirectory;
259                 this.plugins = base.plugins;
260                 this.locations = base.locations;
261                 this.importedFrom = base.importedFrom;
262             } else {
263                 this.base = base;
264             }
265         }
266 
267         @Nonnull
268         public Builder excludeDefaults(String excludeDefaults) {
269             this.excludeDefaults = excludeDefaults;
270             return this;
271         }
272 
273         @Nonnull
274         public Builder outputDirectory(String outputDirectory) {
275             this.outputDirectory = outputDirectory;
276             return this;
277         }
278 
279         @Nonnull
280         public Builder plugins(Collection<ReportPlugin> plugins) {
281             this.plugins = plugins;
282             return this;
283         }
284 
285 
286         @Nonnull
287         public Builder location(Object key, InputLocation location) {
288             if (location != null) {
289                 if (!(this.locations instanceof HashMap)) {
290                     this.locations = this.locations != null ? new HashMap<>(this.locations) : new HashMap<>();
291                 }
292                 this.locations.put(key, location);
293             }
294             return this;
295         }
296 
297         @Nonnull
298         public Builder importedFrom(InputLocation importedFrom) {
299             this.importedFrom = importedFrom;
300             return this;
301         }
302 
303         @Nonnull
304         public Reporting build() {
305             // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
306             if (base != null
307                     && (excludeDefaults == null || excludeDefaults == base.excludeDefaults)
308                     && (outputDirectory == null || outputDirectory == base.outputDirectory)
309                     && (plugins == null || plugins == base.plugins)
310             ) {
311                 return base;
312             }
313             return new Reporting(this);
314         }
315     }
316 
317 
318             
319     public boolean isExcludeDefaults() {
320         return (getExcludeDefaults() != null) ? Boolean.parseBoolean(getExcludeDefaults()) : false;
321     }
322 
323             
324           
325 }