1 | |
package org.apache.maven.index.artifact; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public class Gav |
29 | |
{ |
30 | |
|
31 | |
|
32 | |
|
33 | 3 | public enum HashType |
34 | |
{ |
35 | 1 | sha1, md5 |
36 | |
} |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 2 | public enum SignatureType |
42 | |
{ |
43 | 1 | gpg; |
44 | |
|
45 | |
@Override |
46 | |
public String toString() |
47 | |
{ |
48 | 0 | switch ( this ) |
49 | |
{ |
50 | |
case gpg: |
51 | |
{ |
52 | 0 | return "asc"; |
53 | |
} |
54 | |
|
55 | |
default: |
56 | |
{ |
57 | 0 | return "unknown-signature-type"; |
58 | |
} |
59 | |
} |
60 | |
} |
61 | |
} |
62 | |
|
63 | |
private final String groupId; |
64 | |
|
65 | |
private final String artifactId; |
66 | |
|
67 | |
private final String version; |
68 | |
|
69 | |
private final String baseVersion; |
70 | |
|
71 | |
private final String classifier; |
72 | |
|
73 | |
private final String extension; |
74 | |
|
75 | |
private final Integer snapshotBuildNumber; |
76 | |
|
77 | |
private final Long snapshotTimeStamp; |
78 | |
|
79 | |
private final String name; |
80 | |
|
81 | |
private final boolean snapshot; |
82 | |
|
83 | |
private final boolean hash; |
84 | |
|
85 | |
private final HashType hashType; |
86 | |
|
87 | |
private final boolean signature; |
88 | |
|
89 | |
private final SignatureType signatureType; |
90 | |
|
91 | |
public Gav( String groupId, String artifactId, String version ) |
92 | |
{ |
93 | 0 | this( groupId, artifactId, version, null, null, null, null, null, false, null, false, null ); |
94 | 0 | } |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public Gav( String groupId, String artifactId, String version, String classifier, String extension, |
116 | |
Integer snapshotBuildNumber, Long snapshotTimeStamp, String name, boolean snapshot, boolean hash, |
117 | |
HashType hashType, boolean signature, SignatureType signatureType ) |
118 | |
{ |
119 | 0 | this( groupId, artifactId, version, classifier, extension, snapshotBuildNumber, snapshotTimeStamp, name, hash, |
120 | |
hashType, signature, signatureType ); |
121 | 0 | } |
122 | |
|
123 | |
public Gav( String groupId, String artifactId, String version, String classifier, String extension, |
124 | |
Integer snapshotBuildNumber, Long snapshotTimeStamp, String name, boolean hash, HashType hashType, |
125 | |
boolean signature, SignatureType signatureType ) |
126 | 55 | { |
127 | 55 | this.groupId = groupId; |
128 | 55 | this.artifactId = artifactId; |
129 | 55 | this.version = version; |
130 | 55 | this.snapshot = VersionUtils.isSnapshot( version ); |
131 | |
|
132 | 55 | if ( !snapshot ) |
133 | |
{ |
134 | 21 | this.baseVersion = null; |
135 | |
} |
136 | |
else |
137 | |
{ |
138 | 34 | if ( version.contains( "SNAPSHOT" ) ) |
139 | |
{ |
140 | |
|
141 | 18 | this.baseVersion = null; |
142 | |
} |
143 | |
else |
144 | |
{ |
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | 16 | String tempBaseVersion = version.substring( 0, version.lastIndexOf( '-' ) ); |
160 | 16 | tempBaseVersion = tempBaseVersion.substring( 0, tempBaseVersion.length() - 15 ); |
161 | |
|
162 | 16 | if ( tempBaseVersion.length() > 0 ) |
163 | |
{ |
164 | 15 | this.baseVersion = tempBaseVersion + "SNAPSHOT"; |
165 | |
} |
166 | |
else |
167 | |
{ |
168 | 1 | this.baseVersion = "SNAPSHOT"; |
169 | |
} |
170 | |
|
171 | |
} |
172 | |
} |
173 | |
|
174 | 55 | this.classifier = classifier; |
175 | 55 | this.extension = extension; |
176 | 55 | this.snapshotBuildNumber = snapshotBuildNumber; |
177 | 55 | this.snapshotTimeStamp = snapshotTimeStamp; |
178 | 55 | this.name = name; |
179 | 55 | this.hash = hash; |
180 | 55 | this.hashType = hashType; |
181 | 55 | this.signature = signature; |
182 | 55 | this.signatureType = signatureType; |
183 | 55 | } |
184 | |
|
185 | |
public String getGroupId() |
186 | |
{ |
187 | 84 | return groupId; |
188 | |
} |
189 | |
|
190 | |
public String getArtifactId() |
191 | |
{ |
192 | 84 | return artifactId; |
193 | |
} |
194 | |
|
195 | |
public String getVersion() |
196 | |
{ |
197 | 114 | return version; |
198 | |
} |
199 | |
|
200 | |
public String getBaseVersion() |
201 | |
{ |
202 | 69 | if ( baseVersion == null ) |
203 | |
{ |
204 | 44 | return getVersion(); |
205 | |
} |
206 | |
else |
207 | |
{ |
208 | 25 | return baseVersion; |
209 | |
} |
210 | |
} |
211 | |
|
212 | |
public String getClassifier() |
213 | |
{ |
214 | 108 | return classifier; |
215 | |
} |
216 | |
|
217 | |
public String getExtension() |
218 | |
{ |
219 | 79 | return extension; |
220 | |
} |
221 | |
|
222 | |
public String getName() |
223 | |
{ |
224 | 121 | return name; |
225 | |
} |
226 | |
|
227 | |
public boolean isSnapshot() |
228 | |
{ |
229 | 47 | return snapshot; |
230 | |
} |
231 | |
|
232 | |
public Integer getSnapshotBuildNumber() |
233 | |
{ |
234 | 43 | return snapshotBuildNumber; |
235 | |
} |
236 | |
|
237 | |
public Long getSnapshotTimeStamp() |
238 | |
{ |
239 | 43 | return snapshotTimeStamp; |
240 | |
} |
241 | |
|
242 | |
public boolean isHash() |
243 | |
{ |
244 | 58 | return hash; |
245 | |
} |
246 | |
|
247 | |
public HashType getHashType() |
248 | |
{ |
249 | 46 | return hashType; |
250 | |
} |
251 | |
|
252 | |
public boolean isSignature() |
253 | |
{ |
254 | 5 | return signature; |
255 | |
} |
256 | |
|
257 | |
public SignatureType getSignatureType() |
258 | |
{ |
259 | 2 | return signatureType; |
260 | |
} |
261 | |
|
262 | |
@Override |
263 | |
public int hashCode() |
264 | |
{ |
265 | 0 | int result = 1; |
266 | 0 | result = 31 * result + ( groupId == null ? 0 : groupId.hashCode() ); |
267 | 0 | result = 31 * result + ( artifactId == null ? 0 : artifactId.hashCode() ); |
268 | 0 | result = 31 * result + ( version == null ? 0 : version.hashCode() ); |
269 | 0 | result = 31 * result + ( baseVersion == null ? 0 : baseVersion.hashCode() ); |
270 | 0 | result = 31 * result + ( classifier == null ? 0 : classifier.hashCode() ); |
271 | 0 | result = 31 * result + ( extension == null ? 0 : extension.hashCode() ); |
272 | 0 | result = 31 * result + ( name == null ? 0 : name.hashCode() ); |
273 | 0 | result = 31 * result + ( snapshot ? 1231 : 1237 ); |
274 | 0 | result = 31 * result + ( snapshotBuildNumber == null ? 0 : snapshotBuildNumber.hashCode() ); |
275 | 0 | result = 31 * result + ( snapshotTimeStamp == null ? 0 : snapshotTimeStamp.hashCode() ); |
276 | 0 | result = 31 * result + ( hash ? 1231 : 1237 ); |
277 | 0 | result = 31 * result + ( hashType == null ? 0 : hashType.hashCode() ); |
278 | 0 | result = 31 * result + ( signature ? 1231 : 1237 ); |
279 | 0 | result = 31 * result + ( signatureType == null ? 0 : signatureType.hashCode() ); |
280 | 0 | return result; |
281 | |
} |
282 | |
|
283 | |
@Override |
284 | |
public boolean equals( Object obj ) |
285 | |
{ |
286 | 0 | if ( this == obj ) |
287 | |
{ |
288 | 0 | return true; |
289 | |
} |
290 | 0 | if ( obj == null ) |
291 | |
{ |
292 | 0 | return false; |
293 | |
} |
294 | 0 | if ( getClass() != obj.getClass() ) |
295 | |
{ |
296 | 0 | return false; |
297 | |
} |
298 | |
|
299 | 0 | Gav other = (Gav) obj; |
300 | |
|
301 | 0 | if ( groupId == null ) |
302 | |
{ |
303 | 0 | if ( other.groupId != null ) |
304 | |
{ |
305 | 0 | return false; |
306 | |
} |
307 | |
} |
308 | 0 | else if ( !groupId.equals( other.groupId ) ) |
309 | |
{ |
310 | 0 | return false; |
311 | |
} |
312 | |
|
313 | 0 | if ( artifactId == null ) |
314 | |
{ |
315 | 0 | if ( other.artifactId != null ) |
316 | |
{ |
317 | 0 | return false; |
318 | |
} |
319 | |
} |
320 | 0 | else if ( !artifactId.equals( other.artifactId ) ) |
321 | |
{ |
322 | 0 | return false; |
323 | |
} |
324 | |
|
325 | 0 | if ( version == null ) |
326 | |
{ |
327 | 0 | if ( other.version != null ) |
328 | |
{ |
329 | 0 | return false; |
330 | |
} |
331 | |
} |
332 | 0 | else if ( !version.equals( other.version ) ) |
333 | |
{ |
334 | 0 | return false; |
335 | |
} |
336 | |
|
337 | 0 | if ( baseVersion == null ) |
338 | |
{ |
339 | 0 | if ( other.baseVersion != null ) |
340 | |
{ |
341 | 0 | return false; |
342 | |
} |
343 | |
} |
344 | 0 | else if ( !baseVersion.equals( other.baseVersion ) ) |
345 | |
{ |
346 | 0 | return false; |
347 | |
} |
348 | |
|
349 | 0 | if ( classifier == null ) |
350 | |
{ |
351 | 0 | if ( other.classifier != null ) |
352 | |
{ |
353 | 0 | return false; |
354 | |
} |
355 | |
} |
356 | 0 | else if ( !classifier.equals( other.classifier ) ) |
357 | |
{ |
358 | 0 | return false; |
359 | |
} |
360 | |
|
361 | 0 | if ( extension == null ) |
362 | |
{ |
363 | 0 | if ( other.extension != null ) |
364 | |
{ |
365 | 0 | return false; |
366 | |
} |
367 | |
} |
368 | 0 | else if ( !extension.equals( other.extension ) ) |
369 | |
{ |
370 | 0 | return false; |
371 | |
} |
372 | |
|
373 | 0 | if ( name == null ) |
374 | |
{ |
375 | 0 | if ( other.name != null ) |
376 | |
{ |
377 | 0 | return false; |
378 | |
} |
379 | |
} |
380 | 0 | else if ( !name.equals( other.name ) ) |
381 | |
{ |
382 | 0 | return false; |
383 | |
} |
384 | |
|
385 | 0 | if ( snapshot != other.snapshot ) |
386 | |
{ |
387 | 0 | return false; |
388 | |
} |
389 | |
|
390 | 0 | if ( snapshotBuildNumber == null ) |
391 | |
{ |
392 | 0 | if ( other.snapshotBuildNumber != null ) |
393 | |
{ |
394 | 0 | return false; |
395 | |
} |
396 | |
} |
397 | 0 | else if ( !snapshotBuildNumber.equals( other.snapshotBuildNumber ) ) |
398 | |
{ |
399 | 0 | return false; |
400 | |
} |
401 | |
|
402 | 0 | if ( snapshotTimeStamp == null ) |
403 | |
{ |
404 | 0 | if ( other.snapshotTimeStamp != null ) |
405 | |
{ |
406 | 0 | return false; |
407 | |
} |
408 | |
} |
409 | 0 | else if ( !snapshotTimeStamp.equals( other.snapshotTimeStamp ) ) |
410 | |
{ |
411 | 0 | return false; |
412 | |
} |
413 | |
|
414 | 0 | if ( hash != other.hash ) |
415 | |
{ |
416 | 0 | return false; |
417 | |
} |
418 | |
|
419 | 0 | if ( hashType == null ) |
420 | |
{ |
421 | 0 | if ( other.hashType != null ) |
422 | |
{ |
423 | 0 | return false; |
424 | |
} |
425 | |
} |
426 | 0 | else if ( !hashType.equals( other.hashType ) ) |
427 | |
{ |
428 | 0 | return false; |
429 | |
} |
430 | |
|
431 | 0 | if ( signature != other.signature ) |
432 | |
{ |
433 | 0 | return false; |
434 | |
} |
435 | |
|
436 | 0 | if ( signatureType == null ) |
437 | |
{ |
438 | 0 | if ( other.signatureType != null ) |
439 | |
{ |
440 | 0 | return false; |
441 | |
} |
442 | |
} |
443 | 0 | else if ( !signatureType.equals( other.signatureType ) ) |
444 | |
{ |
445 | 0 | return false; |
446 | |
} |
447 | |
|
448 | 0 | return true; |
449 | |
} |
450 | |
} |