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