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