1
2
3
4
5
6 package org.apache.maven.model;
7
8
9
10
11
12
13 @SuppressWarnings( "all" )
14 public class PluginContainer
15 implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
16 {
17
18
19
20
21
22
23
24
25 private java.util.List<Plugin> plugins;
26
27
28
29
30 private java.util.Map<Object, InputLocation> locations;
31
32
33
34
35 private InputLocation location;
36
37
38
39
40 private InputLocation pluginsLocation;
41
42
43
44
45
46
47
48
49
50
51
52 public void addPlugin( Plugin plugin )
53 {
54 getPlugins().add( plugin );
55 }
56
57
58
59
60
61
62 public PluginContainer clone()
63 {
64 try
65 {
66 PluginContainer copy = (PluginContainer) super.clone();
67
68 if ( this.plugins != null )
69 {
70 copy.plugins = new java.util.ArrayList<Plugin>();
71 for ( Plugin item : this.plugins )
72 {
73 copy.plugins.add( ( (Plugin) item).clone() );
74 }
75 }
76
77 if ( copy.locations != null )
78 {
79 copy.locations = new java.util.LinkedHashMap( copy.locations );
80 }
81
82 return copy;
83 }
84 catch ( java.lang.Exception ex )
85 {
86 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
87 + " does not support clone()" ).initCause( ex );
88 }
89 }
90
91
92
93
94
95
96
97 public InputLocation getLocation( Object key )
98 {
99 if ( key instanceof String )
100 {
101 switch ( ( String ) key )
102 {
103 case "" :
104 {
105 return this.location;
106 }
107 case "plugins" :
108 {
109 return pluginsLocation;
110 }
111 default :
112 {
113 return getOtherLocation( key );
114 }
115 }
116 }
117 else
118 {
119 return getOtherLocation( key );
120 }
121 }
122
123
124
125
126
127
128
129 public void setLocation( Object key, InputLocation location )
130 {
131 if ( key instanceof String )
132 {
133 switch ( ( String ) key )
134 {
135 case "" :
136 {
137 this.location = location;
138 return;
139 }
140 case "plugins" :
141 {
142 pluginsLocation = location;
143 return;
144 }
145 default :
146 {
147 setOtherLocation( key, location );
148 return;
149 }
150 }
151 }
152 else
153 {
154 setOtherLocation( key, location );
155 }
156 }
157
158
159
160
161
162
163
164 public void setOtherLocation( Object key, InputLocation location )
165 {
166 if ( location != null )
167 {
168 if ( this.locations == null )
169 {
170 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
171 }
172 this.locations.put( key, location );
173 }
174 }
175
176
177
178
179
180
181
182 private InputLocation getOtherLocation( Object key )
183 {
184 return ( locations != null ) ? locations.get( key ) : null;
185 }
186
187
188
189
190
191
192 public java.util.List<Plugin> getPlugins()
193 {
194 if ( this.plugins == null )
195 {
196 this.plugins = new java.util.ArrayList<Plugin>();
197 }
198
199 return this.plugins;
200 }
201
202
203
204
205
206
207 public void removePlugin( Plugin plugin )
208 {
209 getPlugins().remove( plugin );
210 }
211
212
213
214
215
216
217 public void setPlugins( java.util.List<Plugin> plugins )
218 {
219 this.plugins = plugins;
220 }
221
222
223
224 java.util.Map<String, Plugin> pluginMap;
225
226
227
228
229 public synchronized void flushPluginMap()
230 {
231 this.pluginMap = null;
232 }
233
234
235
236
237
238 public synchronized java.util.Map<String, Plugin> getPluginsAsMap()
239 {
240 if ( pluginMap == null )
241 {
242 pluginMap = new java.util.LinkedHashMap<String, Plugin>();
243 if ( plugins != null )
244 {
245 for ( java.util.Iterator<Plugin> it = plugins.iterator(); it.hasNext(); )
246 {
247 Plugin plugin = (Plugin) it.next();
248 pluginMap.put( plugin.getKey(), plugin );
249 }
250 }
251 }
252
253 return pluginMap;
254 }
255
256
257
258
259 @Override
260 public String toString()
261 {
262 return "PluginContainer {}";
263 }
264
265
266 }