View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //   Generated by Maven, any modifications will be overwritten.
3   // ==============================================================
4   package org.apache.maven.api.model;
5   
6   import java.io.Serializable;
7   import java.util.ArrayList;
8   import java.util.Collection;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import org.apache.maven.api.annotations.Experimental;
14  import org.apache.maven.api.annotations.Generated;
15  import org.apache.maven.api.annotations.Immutable;
16  import org.apache.maven.api.annotations.Nonnull;
17  import org.apache.maven.api.annotations.NotThreadSafe;
18  import org.apache.maven.api.annotations.ThreadSafe;
19  
20  /**
21   * Section for management of reports and their configuration.
22   */
23  @Experimental
24  @Generated @ThreadSafe @Immutable
25  public class Reporting
26      implements Serializable, InputLocationTracker
27  {
28      /**
29       * If true, then the default reports are not included in the site generation.
30       * This includes the reports in the "Project Info" menu. Note: While the type
31       * of this field is {@code String} for technical reasons, the semantic type is actually
32       * {@code Boolean}. Default value is {@code false}.
33       */
34      final String excludeDefaults;
35      /**
36       * Where to store all of the generated reports. The default is
37       * {@code ${project.build.directory}/site}.
38       */
39      final String outputDirectory;
40      /**
41       * The reporting plugins to use and their configuration.
42       */
43      final List<ReportPlugin> plugins;
44      /** Location of the xml element for this object. */
45      final InputLocation location;
46      /** Location of the xml element for the field excludeDefaults. */
47      final InputLocation excludeDefaultsLocation;
48      /** Location of the xml element for the field outputDirectory. */
49      final InputLocation outputDirectoryLocation;
50      /** Location of the xml element for the field plugins. */
51      final InputLocation pluginsLocation;
52      /** Other locations */
53      final Map<Object, InputLocation> locations;
54  
55      /**
56        * Constructor for this class, package protected.
57        * @see Builder#build()
58        */
59      Reporting(
60          String excludeDefaults,
61          String outputDirectory,
62          Collection<ReportPlugin> plugins,
63          Map<Object, InputLocation> locations,
64          InputLocation location,
65          InputLocation excludeDefaultsLocation,
66          InputLocation outputDirectoryLocation,
67          InputLocation pluginsLocation
68      )
69      {
70          this.excludeDefaults = excludeDefaults;
71          this.outputDirectory = outputDirectory;
72          this.plugins = ImmutableCollections.copy( plugins );
73          this.locations = ImmutableCollections.copy( locations );
74          this.location = location;
75          this.excludeDefaultsLocation = excludeDefaultsLocation;
76          this.outputDirectoryLocation = outputDirectoryLocation;
77          this.pluginsLocation = pluginsLocation;
78      }
79  
80      /**
81       * If true, then the default reports are not included in the site generation.
82       * This includes the reports in the "Project Info" menu. Note: While the type
83       * of this field is {@code String} for technical reasons, the semantic type is actually
84       * {@code Boolean}. Default value is {@code false}.
85       *
86       * @return a {@code String}
87       */
88      public String getExcludeDefaults()
89      {
90          return this.excludeDefaults;
91      }
92  
93      /**
94       * Where to store all of the generated reports. The default is
95       * {@code ${project.build.directory}/site}.
96       *
97       * @return a {@code String}
98       */
99      public String getOutputDirectory()
100     {
101         return this.outputDirectory;
102     }
103 
104     /**
105      * The reporting plugins to use and their configuration.
106      *
107      * @return a {@code List<ReportPlugin>}
108      */
109     @Nonnull
110     public List<ReportPlugin> getPlugins()
111     {
112         return this.plugins;
113     }
114 
115     /**
116      * Gets the location of the specified field in the input source.
117      */
118     public InputLocation getLocation( Object key )
119     {
120         if ( key instanceof String )
121         {
122             switch ( ( String ) key )
123             {
124                 case "":
125                     return location;
126                 case "excludeDefaults":
127                     return excludeDefaultsLocation;
128                 case "outputDirectory":
129                     return outputDirectoryLocation;
130                 case "plugins":
131                     return pluginsLocation;
132             }
133         }
134         return locations != null ? locations.get( key ) : null;
135     }
136 
137     /**
138      * Creates a new builder with this object as the basis.
139      *
140      * @return a {@code Builder}
141      */
142     @Nonnull
143     public Builder with()
144     {
145         return newBuilder( this );
146     }
147     /**
148      * Creates a new {@code Reporting} instance using the specified excludeDefaults.
149      *
150      * @param excludeDefaults the new {@code String} to use
151      * @return a {@code Reporting} with the specified excludeDefaults
152      */
153     @Nonnull
154     public Reporting withExcludeDefaults( String excludeDefaults )
155     {
156         return with().excludeDefaults( excludeDefaults ).build();
157     }
158     /**
159      * Creates a new {@code Reporting} instance using the specified outputDirectory.
160      *
161      * @param outputDirectory the new {@code String} to use
162      * @return a {@code Reporting} with the specified outputDirectory
163      */
164     @Nonnull
165     public Reporting withOutputDirectory( String outputDirectory )
166     {
167         return with().outputDirectory( outputDirectory ).build();
168     }
169     /**
170      * Creates a new {@code Reporting} instance using the specified plugins.
171      *
172      * @param plugins the new {@code Collection<ReportPlugin>} to use
173      * @return a {@code Reporting} with the specified plugins
174      */
175     @Nonnull
176     public Reporting withPlugins( Collection<ReportPlugin> plugins )
177     {
178         return with().plugins( plugins ).build();
179     }
180 
181     /**
182      * Creates a new {@code Reporting} instance.
183      * Equivalent to {@code newInstance( true )}.
184      * @see #newInstance(boolean)
185      *
186      * @return a new {@code Reporting}
187      */
188     @Nonnull
189     public static Reporting newInstance()
190     {
191         return newInstance( true );
192     }
193 
194     /**
195      * Creates a new {@code Reporting} instance using default values or not.
196      * Equivalent to {@code newBuilder( withDefaults ).build()}.
197      *
198      * @param withDefaults the boolean indicating whether default values should be used
199      * @return a new {@code Reporting}
200      */
201     @Nonnull
202     public static Reporting newInstance( boolean withDefaults )
203     {
204         return newBuilder( withDefaults ).build();
205     }
206 
207     /**
208      * Creates a new {@code Reporting} builder instance.
209      * Equivalent to {@code newBuilder( true )}.
210      * @see #newBuilder(boolean)
211      *
212      * @return a new {@code Builder}
213      */
214     @Nonnull
215     public static Builder newBuilder()
216     {
217         return newBuilder( true );
218     }
219 
220     /**
221      * Creates a new {@code Reporting} builder instance using default values or not.
222      *
223      * @param withDefaults the boolean indicating whether default values should be used
224      * @return a new {@code Builder}
225      */
226     @Nonnull
227     public static Builder newBuilder( boolean withDefaults )
228     {
229         return new Builder( withDefaults );
230     }
231 
232     /**
233      * Creates a new {@code Reporting} builder instance using the specified object as a basis.
234      * Equivalent to {@code newBuilder( from, false )}.
235      *
236      * @param from the {@code Reporting} instance to use as a basis
237      * @return a new {@code Builder}
238      */
239     @Nonnull
240     public static Builder newBuilder( Reporting from )
241     {
242         return newBuilder( from, false );
243     }
244 
245     /**
246      * Creates a new {@code Reporting} builder instance using the specified object as a basis.
247      *
248      * @param from the {@code Reporting} instance to use as a basis
249      * @param forceCopy the boolean indicating if a copy should be forced
250      * @return a new {@code Builder}
251      */
252     @Nonnull
253     public static Builder newBuilder( Reporting from, boolean forceCopy )
254     {
255         return new Builder( from, forceCopy );
256     }
257 
258     /**
259      * Builder class used to create Reporting instances.
260      * @see #with()
261      * @see #newBuilder()
262      */
263     @NotThreadSafe
264     public static class Builder
265     {
266         Reporting base;
267         String excludeDefaults;
268         String outputDirectory;
269         Collection<ReportPlugin> plugins;
270         Map<Object, InputLocation> locations;
271 
272         Builder( boolean withDefaults )
273         {
274             if ( withDefaults )
275             {
276             }
277         }
278 
279         Builder( Reporting base, boolean forceCopy )
280         {
281             if ( forceCopy )
282             {
283                 this.excludeDefaults = base.excludeDefaults;
284                 this.outputDirectory = base.outputDirectory;
285                 this.plugins = base.plugins;
286             }
287             else
288             {
289                 this.base = base;
290             }
291         }
292 
293         @Nonnull
294         public Builder excludeDefaults( String excludeDefaults )
295         {
296             this.excludeDefaults = excludeDefaults;
297             return this;
298         }
299 
300         @Nonnull
301         public Builder outputDirectory( String outputDirectory )
302         {
303             this.outputDirectory = outputDirectory;
304             return this;
305         }
306 
307         @Nonnull
308         public Builder plugins( Collection<ReportPlugin> plugins )
309         {
310             this.plugins = plugins;
311             return this;
312         }
313 
314 
315         @Nonnull
316         public Builder location( Object key, InputLocation location )
317         {
318             if ( location != null )
319             {
320                 if ( this.locations == null )
321                 {
322                     this.locations = new HashMap<>();
323                 }
324                 this.locations.put( key, location );
325             }
326             return this;
327         }
328 
329         @Nonnull
330         public Reporting build()
331         {
332             if ( base != null
333                     && ( excludeDefaults == null || excludeDefaults == base.excludeDefaults )
334                     && ( outputDirectory == null || outputDirectory == base.outputDirectory )
335                     && ( plugins == null || plugins == base.plugins )
336             )
337             {
338                 return base;
339             }
340             Map<Object, InputLocation> locations = null;
341             InputLocation location = null;
342             InputLocation excludeDefaultsLocation = null;
343             InputLocation outputDirectoryLocation = null;
344             InputLocation pluginsLocation = null;
345             if ( this.locations != null )
346             {
347                 locations = this.locations;
348                 location = locations.remove( "" );
349                 excludeDefaultsLocation = locations.remove( "excludeDefaults" );
350                 outputDirectoryLocation = locations.remove( "outputDirectory" );
351                 pluginsLocation = locations.remove( "plugins" );
352             }
353             return new Reporting(
354                 excludeDefaults != null ? excludeDefaults : ( base != null ? base.excludeDefaults : null ),
355                 outputDirectory != null ? outputDirectory : ( base != null ? base.outputDirectory : null ),
356                 plugins != null ? plugins : ( base != null ? base.plugins : null ),
357                 locations != null ? locations : ( base != null ? base.locations : null ),
358                 location != null ? location : ( base != null ? base.location : null ),
359                 excludeDefaultsLocation != null ? excludeDefaultsLocation : ( base != null ? base.excludeDefaultsLocation : null ),
360                 outputDirectoryLocation != null ? outputDirectoryLocation : ( base != null ? base.outputDirectoryLocation : null ),
361                 pluginsLocation != null ? pluginsLocation : ( base != null ? base.pluginsLocation : null )
362             );
363         }
364     }
365 
366 
367             
368     public boolean isExcludeDefaults()
369     {
370         return ( getExcludeDefaults() != null ) ? Boolean.parseBoolean( getExcludeDefaults() ) : false;
371     }
372 
373             
374           
375 }