1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.apache.maven.model;
25
26
27
28
29
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
38
39
40
41
42
43 private java.util.List<Plugin> plugins;
44
45
46
47
48 private java.util.Map<Object, InputLocation> locations;
49
50
51
52
53 private InputLocation location;
54
55
56
57
58 private InputLocation pluginsLocation;
59
60
61
62
63
64
65
66
67
68
69
70 public void addPlugin( Plugin plugin )
71 {
72 getPlugins().add( plugin );
73 }
74
75
76
77
78
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 }
108
109
110
111
112
113
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 }
140
141
142
143
144
145
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 }
175
176
177
178
179
180
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 }
193
194
195
196
197
198
199
200 private InputLocation getOtherLocation( Object key )
201 {
202 return ( locations != null ) ? locations.get( key ) : null;
203 }
204
205
206
207
208
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 }
219
220
221
222
223
224
225 public void removePlugin( Plugin plugin )
226 {
227 getPlugins().remove( plugin );
228 }
229
230
231
232
233
234
235 public void setPlugins( java.util.List<Plugin> plugins )
236 {
237 this.plugins = plugins;
238 }
239
240
241
242 java.util.Map<String, Plugin> pluginMap;
243
244
245
246
247 public synchronized void flushPluginMap()
248 {
249 this.pluginMap = null;
250 }
251
252
253
254
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 }