This project has retired. For details please refer to its Attic page.
ArtifactReference xref
View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.7,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.archiva.model;
7   
8   /**
9    * Class ArtifactReference.
10   * 
11   * @version $Revision$ $Date$
12   */
13  @SuppressWarnings( "all" )
14  public class ArtifactReference
15      implements java.io.Serializable
16  {
17  
18        //--------------------------/
19       //- Class/Member Variables -/
20      //--------------------------/
21  
22      /**
23       * 
24       *             The Group ID of the repository content.
25       *           
26       */
27      private String groupId;
28  
29      /**
30       * 
31       *             The Artifact ID of the repository content.
32       *           
33       */
34      private String artifactId;
35  
36      /**
37       * 
38       *             The version of the repository content.
39       *           
40       */
41      private String version;
42  
43      /**
44       * 
45       *             The classifier for this artifact.
46       *           
47       */
48      private String classifier;
49  
50      /**
51       * 
52       *             The type of artifact.
53       *           
54       */
55      private String type;
56  
57  
58        //-----------/
59       //- Methods -/
60      //-----------/
61  
62      /**
63       * Get the Artifact ID of the repository content.
64       * 
65       * @return String
66       */
67      public String getArtifactId()
68      {
69          return this.artifactId;
70      } //-- String getArtifactId()
71  
72      /**
73       * Get the classifier for this artifact.
74       * 
75       * @return String
76       */
77      public String getClassifier()
78      {
79          return this.classifier;
80      } //-- String getClassifier()
81  
82      /**
83       * Get the Group ID of the repository content.
84       * 
85       * @return String
86       */
87      public String getGroupId()
88      {
89          return this.groupId;
90      } //-- String getGroupId()
91  
92      /**
93       * Get the type of artifact.
94       * 
95       * @return String
96       */
97      public String getType()
98      {
99          return this.type;
100     } //-- String getType()
101 
102     /**
103      * Get the version of the repository content.
104      * 
105      * @return String
106      */
107     public String getVersion()
108     {
109         return this.version;
110     } //-- String getVersion()
111 
112     /**
113      * Set the Artifact ID of the repository content.
114      * 
115      * @param artifactId
116      */
117     public void setArtifactId( String artifactId )
118     {
119         this.artifactId = artifactId;
120     } //-- void setArtifactId( String )
121 
122     /**
123      * Set the classifier for this artifact.
124      * 
125      * @param classifier
126      */
127     public void setClassifier( String classifier )
128     {
129         this.classifier = classifier;
130     } //-- void setClassifier( String )
131 
132     /**
133      * Set the Group ID of the repository content.
134      * 
135      * @param groupId
136      */
137     public void setGroupId( String groupId )
138     {
139         this.groupId = groupId;
140     } //-- void setGroupId( String )
141 
142     /**
143      * Set the type of artifact.
144      * 
145      * @param type
146      */
147     public void setType( String type )
148     {
149         this.type = type;
150     } //-- void setType( String )
151 
152     /**
153      * Set the version of the repository content.
154      * 
155      * @param version
156      */
157     public void setVersion( String version )
158     {
159         this.version = version;
160     } //-- void setVersion( String )
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 }