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 Extension
33 implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
34 {
35
36
37
38
39
40
41
42
43 private String groupId;
44
45
46
47
48 private String artifactId;
49
50
51
52
53 private String version;
54
55
56
57
58 private java.util.Map<Object, InputLocation> locations;
59
60
61
62
63 private InputLocation location;
64
65
66
67
68 private InputLocation groupIdLocation;
69
70
71
72
73 private InputLocation artifactIdLocation;
74
75
76
77
78 private InputLocation versionLocation;
79
80
81
82
83
84
85
86
87
88
89
90 public Extension clone()
91 {
92 try
93 {
94 Extension copy = (Extension) super.clone();
95
96 if ( copy.locations != null )
97 {
98 copy.locations = new java.util.LinkedHashMap( copy.locations );
99 }
100
101 return copy;
102 }
103 catch ( java.lang.Exception ex )
104 {
105 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
106 + " does not support clone()" ).initCause( ex );
107 }
108 }
109
110
111
112
113
114
115 public String getArtifactId()
116 {
117 return this.artifactId;
118 }
119
120
121
122
123
124
125 public String getGroupId()
126 {
127 return this.groupId;
128 }
129
130
131
132
133
134
135
136 public InputLocation getLocation( Object key )
137 {
138 if ( key instanceof String )
139 {
140 switch ( ( String ) key )
141 {
142 case "" :
143 {
144 return this.location;
145 }
146 case "groupId" :
147 {
148 return groupIdLocation;
149 }
150 case "artifactId" :
151 {
152 return artifactIdLocation;
153 }
154 case "version" :
155 {
156 return versionLocation;
157 }
158 default :
159 {
160 return getOtherLocation( key );
161 }
162 }
163 }
164 else
165 {
166 return getOtherLocation( key );
167 }
168 }
169
170
171
172
173
174
175
176 public void setLocation( Object key, InputLocation location )
177 {
178 if ( key instanceof String )
179 {
180 switch ( ( String ) key )
181 {
182 case "" :
183 {
184 this.location = location;
185 return;
186 }
187 case "groupId" :
188 {
189 groupIdLocation = location;
190 return;
191 }
192 case "artifactId" :
193 {
194 artifactIdLocation = location;
195 return;
196 }
197 case "version" :
198 {
199 versionLocation = location;
200 return;
201 }
202 default :
203 {
204 setOtherLocation( key, location );
205 return;
206 }
207 }
208 }
209 else
210 {
211 setOtherLocation( key, location );
212 }
213 }
214
215
216
217
218
219
220
221 public void setOtherLocation( Object key, InputLocation location )
222 {
223 if ( location != null )
224 {
225 if ( this.locations == null )
226 {
227 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
228 }
229 this.locations.put( key, location );
230 }
231 }
232
233
234
235
236
237
238
239 private InputLocation getOtherLocation( Object key )
240 {
241 return ( locations != null ) ? locations.get( key ) : null;
242 }
243
244
245
246
247
248
249 public String getVersion()
250 {
251 return this.version;
252 }
253
254
255
256
257
258
259 public void setArtifactId( String artifactId )
260 {
261 this.artifactId = artifactId;
262 }
263
264
265
266
267
268
269 public void setGroupId( String groupId )
270 {
271 this.groupId = groupId;
272 }
273
274
275
276
277
278
279 public void setVersion( String version )
280 {
281 this.version = version;
282 }
283
284
285
286
287
288
289 public boolean equals( Object o )
290 {
291 if ( this == o )
292 {
293 return true;
294 }
295
296 if ( !( o instanceof Extension ) )
297 {
298 return false;
299 }
300
301 Extension e = (Extension) o;
302
303 if ( !equal( e.getArtifactId(), getArtifactId() ) )
304 {
305 return false;
306 }
307 else if ( !equal( e.getGroupId(), getGroupId() ) )
308 {
309 return false;
310 }
311 else if ( !equal( e.getVersion(), getVersion() ) )
312 {
313 return false;
314 }
315 return true;
316 }
317
318 private static <T> boolean equal( T obj1, T obj2 )
319 {
320 return ( obj1 != null ) ? obj1.equals( obj2 ) : obj2 == null;
321 }
322
323
324
325
326 public int hashCode()
327 {
328 int result = 17;
329 result = 37 * result + ( getArtifactId() != null ? getArtifactId().hashCode() : 0 );
330 result = 37 * result + ( getGroupId() != null ? getGroupId().hashCode() : 0 );
331 result = 37 * result + ( getVersion() != null ? getVersion().hashCode() : 0 );
332 return result;
333 }
334
335
336 }