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 default plugin information for use in a group of POMs.
23   */
24  @Experimental
25  @Generated @ThreadSafe @Immutable
26  public class PluginManagement
27      extends PluginContainer
28      implements Serializable, InputLocationTracker
29  {
30  
31      /**
32        * Constructor for this class, package protected.
33        * @see Builder#build()
34        */
35      PluginManagement(
36          Collection<Plugin> plugins,
37          Map<Object, InputLocation> locations,
38          InputLocation location,
39          InputLocation pluginsLocation
40      )
41      {
42          super(
43              plugins,
44              locations,
45              location,
46              pluginsLocation
47          );
48      }
49  
50      /**
51       * Gets the location of the specified field in the input source.
52       */
53      public InputLocation getLocation( Object key )
54      {
55          if ( key instanceof String )
56          {
57              switch ( ( String ) key )
58              {
59              }
60          }
61          return super.getLocation( key );
62      }
63  
64      /**
65       * Creates a new builder with this object as the basis.
66       *
67       * @return a {@code Builder}
68       */
69      @Nonnull
70      public Builder with()
71      {
72          return newBuilder( this );
73      }
74      /**
75       * Creates a new {@code PluginManagement} instance using the specified plugins.
76       *
77       * @param plugins the new {@code Collection<Plugin>} to use
78       * @return a {@code PluginManagement} with the specified plugins
79       */
80      @Nonnull
81      public PluginManagement withPlugins( Collection<Plugin> plugins )
82      {
83          return with().plugins( plugins ).build();
84      }
85  
86      /**
87       * Creates a new {@code PluginManagement} instance.
88       * Equivalent to {@code newInstance( true )}.
89       * @see #newInstance(boolean)
90       *
91       * @return a new {@code PluginManagement}
92       */
93      @Nonnull
94      public static PluginManagement newInstance()
95      {
96          return newInstance( true );
97      }
98  
99      /**
100      * Creates a new {@code PluginManagement} instance using default values or not.
101      * Equivalent to {@code newBuilder( withDefaults ).build()}.
102      *
103      * @param withDefaults the boolean indicating whether default values should be used
104      * @return a new {@code PluginManagement}
105      */
106     @Nonnull
107     public static PluginManagement newInstance( boolean withDefaults )
108     {
109         return newBuilder( withDefaults ).build();
110     }
111 
112     /**
113      * Creates a new {@code PluginManagement} builder instance.
114      * Equivalent to {@code newBuilder( true )}.
115      * @see #newBuilder(boolean)
116      *
117      * @return a new {@code Builder}
118      */
119     @Nonnull
120     public static Builder newBuilder()
121     {
122         return newBuilder( true );
123     }
124 
125     /**
126      * Creates a new {@code PluginManagement} builder instance using default values or not.
127      *
128      * @param withDefaults the boolean indicating whether default values should be used
129      * @return a new {@code Builder}
130      */
131     @Nonnull
132     public static Builder newBuilder( boolean withDefaults )
133     {
134         return new Builder( withDefaults );
135     }
136 
137     /**
138      * Creates a new {@code PluginManagement} builder instance using the specified object as a basis.
139      * Equivalent to {@code newBuilder( from, false )}.
140      *
141      * @param from the {@code PluginManagement} instance to use as a basis
142      * @return a new {@code Builder}
143      */
144     @Nonnull
145     public static Builder newBuilder( PluginManagement from )
146     {
147         return newBuilder( from, false );
148     }
149 
150     /**
151      * Creates a new {@code PluginManagement} builder instance using the specified object as a basis.
152      *
153      * @param from the {@code PluginManagement} instance to use as a basis
154      * @param forceCopy the boolean indicating if a copy should be forced
155      * @return a new {@code Builder}
156      */
157     @Nonnull
158     public static Builder newBuilder( PluginManagement from, boolean forceCopy )
159     {
160         return new Builder( from, forceCopy );
161     }
162 
163     /**
164      * Builder class used to create PluginManagement instances.
165      * @see #with()
166      * @see #newBuilder()
167      */
168     @NotThreadSafe
169     public static class Builder
170         extends PluginContainer.Builder
171     {
172         PluginManagement base;
173 
174         Builder( boolean withDefaults )
175         {
176             super( withDefaults );
177             if ( withDefaults )
178             {
179             }
180         }
181 
182         Builder( PluginManagement base, boolean forceCopy )
183         {
184             super( base, forceCopy );
185             if ( forceCopy )
186             {
187             }
188             else
189             {
190                 this.base = base;
191             }
192         }
193 
194         @Nonnull
195         public Builder plugins( Collection<Plugin> plugins )
196         {
197             this.plugins = plugins;
198             return this;
199         }
200 
201 
202         @Nonnull
203         public Builder location( Object key, InputLocation location )
204         {
205             if ( location != null )
206             {
207                 if ( this.locations == null )
208                 {
209                     this.locations = new HashMap<>();
210                 }
211                 this.locations.put( key, location );
212             }
213             return this;
214         }
215 
216         @Nonnull
217         public PluginManagement build()
218         {
219             if ( base != null
220                     && ( plugins == null || plugins == base.plugins )
221             )
222             {
223                 return base;
224             }
225             Map<Object, InputLocation> locations = null;
226             InputLocation location = null;
227             InputLocation pluginsLocation = null;
228             if ( this.locations != null )
229             {
230                 locations = this.locations;
231                 location = locations.remove( "" );
232                 pluginsLocation = locations.remove( "plugins" );
233             }
234             return new PluginManagement(
235                 plugins != null ? plugins : ( base != null ? base.plugins : null ),
236                 locations != null ? locations : ( base != null ? base.locations : null ),
237                 location != null ? location : ( base != null ? base.location : null ),
238                 pluginsLocation != null ? pluginsLocation : ( base != null ? base.pluginsLocation : null )
239             );
240         }
241     }
242 
243 }