001// =================== DO NOT EDIT THIS FILE ==================== 002// Generated by Modello 1.7, 003// any modifications will be overwritten. 004// ============================================================== 005 006package org.apache.archiva.model; 007 008/** 009 * Class ArtifactReference. 010 * 011 * @version $Revision$ $Date$ 012 */ 013@SuppressWarnings( "all" ) 014public class ArtifactReference 015 implements java.io.Serializable 016{ 017 018 //--------------------------/ 019 //- Class/Member Variables -/ 020 //--------------------------/ 021 022 /** 023 * 024 * The Group ID of the repository content. 025 * 026 */ 027 private String groupId; 028 029 /** 030 * 031 * The Artifact ID of the repository content. 032 * 033 */ 034 private String artifactId; 035 036 /** 037 * 038 * The version of the repository content. 039 * 040 */ 041 private String version; 042 043 /** 044 * 045 * The classifier for this artifact. 046 * 047 */ 048 private String classifier; 049 050 /** 051 * 052 * The type of artifact. 053 * 054 */ 055 private String type; 056 057 058 //-----------/ 059 //- Methods -/ 060 //-----------/ 061 062 /** 063 * Get the Artifact ID of the repository content. 064 * 065 * @return String 066 */ 067 public String getArtifactId() 068 { 069 return this.artifactId; 070 } //-- String getArtifactId() 071 072 /** 073 * Get the classifier for this artifact. 074 * 075 * @return String 076 */ 077 public String getClassifier() 078 { 079 return this.classifier; 080 } //-- String getClassifier() 081 082 /** 083 * Get the Group ID of the repository content. 084 * 085 * @return String 086 */ 087 public String getGroupId() 088 { 089 return this.groupId; 090 } //-- String getGroupId() 091 092 /** 093 * Get the type of artifact. 094 * 095 * @return String 096 */ 097 public String getType() 098 { 099 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}