This project has retired. For details please refer to its
Attic page.
ArtifactReference xref
1
2
3
4
5
6 package org.apache.archiva.model;
7
8
9
10
11
12
13 @SuppressWarnings( "all" )
14 public class ArtifactReference
15 implements java.io.Serializable
16 {
17
18
19
20
21
22
23
24
25
26
27 private String groupId;
28
29
30
31
32
33
34 private String artifactId;
35
36
37
38
39
40
41 private String version;
42
43
44
45
46
47
48 private String classifier;
49
50
51
52
53
54
55 private String type;
56
57
58
59
60
61
62
63
64
65
66
67 public String getArtifactId()
68 {
69 return this.artifactId;
70 }
71
72
73
74
75
76
77 public String getClassifier()
78 {
79 return this.classifier;
80 }
81
82
83
84
85
86
87 public String getGroupId()
88 {
89 return this.groupId;
90 }
91
92
93
94
95
96
97 public String getType()
98 {
99 return this.type;
100 }
101
102
103
104
105
106
107 public String getVersion()
108 {
109 return this.version;
110 }
111
112
113
114
115
116
117 public void setArtifactId( String artifactId )
118 {
119 this.artifactId = artifactId;
120 }
121
122
123
124
125
126
127 public void setClassifier( String classifier )
128 {
129 this.classifier = classifier;
130 }
131
132
133
134
135
136
137 public void setGroupId( String groupId )
138 {
139 this.groupId = groupId;
140 }
141
142
143
144
145
146
147 public void setType( String type )
148 {
149 this.type = type;
150 }
151
152
153
154
155
156
157 public void setVersion( String version )
158 {
159 this.version = version;
160 }
161
162
163 private static final long serialVersionUID = -6116764846682178732L;
164
165
166 private static String defaultString( String value )
167 {
168 if ( value == null )
169 {
170 return "";
171 }
172
173 return value.trim();
174 }
175
176 public static String toKey( ArtifactReference artifactReference )
177 {
178 StringBuilder key = new StringBuilder();
179
180 key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" );
181 key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" );
182 key.append( defaultString( artifactReference.getVersion() ) ).append( ":" );
183 key.append( defaultString( artifactReference.getClassifier() ) ).append( ":" );
184 key.append( defaultString( artifactReference.getType() ) );
185
186 return key.toString();
187 }
188
189 public static String toVersionlessKey( ArtifactReference artifactReference )
190 {
191 StringBuilder key = new StringBuilder();
192
193 key.append( defaultString( artifactReference.getGroupId() ) ).append( ":" );
194 key.append( defaultString( artifactReference.getArtifactId() ) ).append( ":" );
195 key.append( defaultString( artifactReference.getClassifier() ) ).append( ":" );
196 key.append( defaultString( artifactReference.getType() ) );
197
198 return key.toString();
199 }
200
201
202 public int hashCode()
203 {
204 final int PRIME = 31;
205 int result = 1;
206 result = PRIME * result + ( ( groupId == null ) ? 0 : groupId.hashCode() );
207 result = PRIME * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() );
208 result = PRIME * result + ( ( version == null ) ? 0 : version.hashCode() );
209 result = PRIME * result + ( ( classifier == null ) ? 0 : classifier.hashCode() );
210 result = PRIME * result + ( ( type == null ) ? 0 : type.hashCode() );
211 return result;
212 }
213
214 public boolean equals( Object obj )
215 {
216 if ( this == obj )
217 {
218 return true;
219 }
220
221 if ( obj == null )
222 {
223 return false;
224 }
225
226 if ( getClass() != obj.getClass() )
227 {
228 return false;
229 }
230
231 final ArtifactReference other = (ArtifactReference) obj;
232
233 if ( groupId == null )
234 {
235 if ( other.groupId != null )
236 {
237 return false;
238 }
239 }
240 else if ( !groupId.equals( other.groupId ) )
241 {
242 return false;
243 }
244
245 if ( artifactId == null )
246 {
247 if ( other.artifactId != null )
248 {
249 return false;
250 }
251 }
252 else if ( !artifactId.equals( other.artifactId ) )
253 {
254 return false;
255 }
256
257 if ( version == null )
258 {
259 if ( other.version != null )
260 {
261 return false;
262 }
263 }
264 else if ( !version.equals( other.version ) )
265 {
266 return false;
267 }
268
269 if ( classifier == null )
270 {
271 if ( other.classifier != null )
272 {
273 return false;
274 }
275 }
276 else if ( !classifier.equals( other.classifier ) )
277 {
278 return false;
279 }
280
281 if ( type == null )
282 {
283 if ( other.type != null )
284 {
285 return false;
286 }
287 }
288 else if ( !type.equals( other.type ) )
289 {
290 return false;
291 }
292
293 return true;
294 }
295
296 }