View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.model;
25  
26  /**
27   * Contains the plugins informations for the project.
28   * 
29   * @version $Revision$ $Date$
30   */
31  @SuppressWarnings( "all" )
32  public class PluginContainer
33      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
34  {
35  
36        //--------------------------/
37       //- Class/Member Variables -/
38      //--------------------------/
39  
40      /**
41       * Field plugins.
42       */
43      private java.util.List<Plugin> plugins;
44  
45      /**
46       * Field locations.
47       */
48      private java.util.Map<Object, InputLocation> locations;
49  
50      /**
51       * Field location.
52       */
53      private InputLocation location;
54  
55      /**
56       * Field pluginsLocation.
57       */
58      private InputLocation pluginsLocation;
59  
60  
61        //-----------/
62       //- Methods -/
63      //-----------/
64  
65      /**
66       * Method addPlugin.
67       * 
68       * @param plugin a plugin object.
69       */
70      public void addPlugin( Plugin plugin )
71      {
72          getPlugins().add( plugin );
73      } //-- void addPlugin( Plugin )
74  
75      /**
76       * Method clone.
77       * 
78       * @return PluginContainer
79       */
80      public PluginContainer clone()
81      {
82          try
83          {
84              PluginContainer copy = (PluginContainer) super.clone();
85  
86              if ( this.plugins != null )
87              {
88                  copy.plugins = new java.util.ArrayList<Plugin>();
89                  for ( Plugin item : this.plugins )
90                  {
91                      copy.plugins.add( ( (Plugin) item).clone() );
92                  }
93              }
94  
95              if ( copy.locations != null )
96              {
97                  copy.locations = new java.util.LinkedHashMap( copy.locations );
98              }
99  
100             return copy;
101         }
102         catch ( java.lang.Exception ex )
103         {
104             throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
105                 + " does not support clone()" ).initCause( ex );
106         }
107     } //-- PluginContainer clone()
108 
109     /**
110      * 
111      * 
112      * @param key a key object.
113      * @return InputLocation
114      */
115     public InputLocation getLocation( Object key )
116     {
117         if ( key instanceof String )
118         {
119             switch ( ( String ) key )
120             {
121                 case "" :
122                 {
123                     return this.location;
124                 }
125                 case "plugins" :
126                 {
127                     return pluginsLocation;
128                 }
129                 default :
130                 {
131                     return getOtherLocation( key );
132                 }
133                 }
134             }
135             else
136             {
137                 return getOtherLocation( key );
138             }
139     } //-- InputLocation getLocation( Object )
140 
141     /**
142      * 
143      * 
144      * @param key a key object.
145      * @param location a location object.
146      */
147     public void setLocation( Object key, InputLocation location )
148     {
149         if ( key instanceof String )
150         {
151             switch ( ( String ) key )
152             {
153                 case "" :
154                 {
155                     this.location = location;
156                     return;
157                 }
158                 case "plugins" :
159                 {
160                     pluginsLocation = location;
161                     return;
162                 }
163                 default :
164                 {
165                     setOtherLocation( key, location );
166                     return;
167                 }
168             }
169         }
170         else
171         {
172             setOtherLocation( key, location );
173         }
174     } //-- void setLocation( Object, InputLocation )
175 
176     /**
177      * 
178      * 
179      * @param key a key object.
180      * @param location a location object.
181      */
182     public void setOtherLocation( Object key, InputLocation location )
183     {
184         if ( location != null )
185         {
186             if ( this.locations == null )
187             {
188                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
189             }
190             this.locations.put( key, location );
191         }
192     } //-- void setOtherLocation( Object, InputLocation )
193 
194     /**
195      * 
196      * 
197      * @param key a key object.
198      * @return InputLocation
199      */
200     private InputLocation getOtherLocation( Object key )
201     {
202         return ( locations != null ) ? locations.get( key ) : null;
203     } //-- InputLocation getOtherLocation( Object )
204 
205     /**
206      * Method getPlugins.
207      * 
208      * @return List
209      */
210     public java.util.List<Plugin> getPlugins()
211     {
212         if ( this.plugins == null )
213         {
214             this.plugins = new java.util.ArrayList<Plugin>();
215         }
216 
217         return this.plugins;
218     } //-- java.util.List<Plugin> getPlugins()
219 
220     /**
221      * Method removePlugin.
222      * 
223      * @param plugin a plugin object.
224      */
225     public void removePlugin( Plugin plugin )
226     {
227         getPlugins().remove( plugin );
228     } //-- void removePlugin( Plugin )
229 
230     /**
231      * Set the list of plugins to use.
232      * 
233      * @param plugins a plugins object.
234      */
235     public void setPlugins( java.util.List<Plugin> plugins )
236     {
237         this.plugins = plugins;
238     } //-- void setPlugins( java.util.List )
239 
240     
241             
242     java.util.Map<String, Plugin> pluginMap;
243 
244     /**
245      * Reset the <code>pluginsMap</code> field to <code>null</code>
246      */
247     public synchronized void flushPluginMap()
248     {
249         this.pluginMap = null;
250     }
251 
252     /**
253      * @return a Map of plugins field with <code>Plugins#getKey()</code> as key
254      * @see org.apache.maven.model.Plugin#getKey()
255      */
256     public synchronized java.util.Map<String, Plugin> getPluginsAsMap()
257     {
258         if ( pluginMap == null )
259         {
260             pluginMap = new java.util.LinkedHashMap<String, Plugin>();
261             if ( plugins != null )
262             {
263                 for ( java.util.Iterator<Plugin> it = plugins.iterator(); it.hasNext(); )
264                 {
265                     Plugin plugin = (Plugin) it.next();
266                     pluginMap.put( plugin.getKey(), plugin );
267                 }
268             }
269         }
270 
271         return pluginMap;
272     }
273             
274           
275     
276             
277      @Override
278      public String toString()
279      {
280          return "PluginContainer {}";
281      }
282             
283           
284 }