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