1 package org.apache.maven.archiva.indexer.record;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
24 * The a record with the fields in the standard index.
26 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
28 public class StandardArtifactIndexRecord
29 extends MinimalArtifactIndexRecord
32 * The SHA-1 checksum of the artifact file.
34 private String sha1Checksum;
37 * The artifact's group.
39 private String groupId;
42 * The artifact's identifier within the group.
44 private String artifactId;
47 * The artifact's version.
49 private String version;
52 * The classifier, if there is one.
54 private String classifier;
57 * The artifact type (from the file).
62 * A list of files (separated by '\n') in the artifact if it is an archive.
67 * The identifier of the repository that the artifact came from.
69 private String repository;
72 * The packaging specified in the POM for this artifact.
74 private String packaging;
77 * The plugin prefix specified in the metadata if the artifact is a plugin.
79 private String pluginPrefix;
82 * The year the project was started.
84 private String inceptionYear;
87 * The description of the project.
89 private String projectDescription;
92 * The name of the project.
94 private String projectName;
97 * The base version (before the snapshot is determined).
99 private String baseVersion;
102 * A list of dependencies for the artifact, each a string of the form <code>groupId:artifactId:version</code>.
104 private List dependencies;
107 * A list of developers in the POM, each a string of the form <code>id:name:email</code>.
109 private List developers;
111 public void setSha1Checksum( String sha1Checksum )
113 this.sha1Checksum = sha1Checksum;
116 public void setGroupId( String groupId )
118 this.groupId = groupId;
121 public void setArtifactId( String artifactId )
123 this.artifactId = artifactId;
126 public void setVersion( String version )
128 this.version = version;
131 public void setClassifier( String classifier )
133 this.classifier = classifier;
136 public void setType( String type )
141 public void setFiles( List files )
146 public void setRepository( String repository )
148 this.repository = repository;
152 * @noinspection RedundantIfStatement
154 public boolean equals( Object obj )
160 if ( obj == null || getClass() != obj.getClass() )
164 if ( !super.equals( obj ) )
169 StandardArtifactIndexRecord that = (StandardArtifactIndexRecord) obj;
171 if ( !artifactId.equals( that.artifactId ) )
175 if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
180 if ( dependencies != null && that.dependencies != null )
182 List sorted = new ArrayList( dependencies );
183 Collections.sort( sorted );
185 List sortedOther = new ArrayList( that.dependencies );
186 Collections.sort( sortedOther );
188 if ( !sorted.equals( sortedOther ) )
193 else if ( !( dependencies == null && that.dependencies == null ) )
198 if ( developers != null ? !developers.equals( that.developers ) : that.developers != null )
202 if ( files != null ? !files.equals( that.files ) : that.files != null )
206 if ( !groupId.equals( that.groupId ) )
210 if ( repository != null ? !repository.equals( that.repository ) : that.repository != null )
214 if ( sha1Checksum != null ? !sha1Checksum.equals( that.sha1Checksum ) : that.sha1Checksum != null )
218 if ( type != null ? !type.equals( that.type ) : that.type != null )
222 if ( !version.equals( that.version ) )
226 if ( !baseVersion.equals( that.baseVersion ) )
230 if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
234 if ( pluginPrefix != null ? !pluginPrefix.equals( that.pluginPrefix ) : that.pluginPrefix != null )
238 if ( projectName != null ? !projectName.equals( that.projectName ) : that.projectName != null )
242 if ( inceptionYear != null ? !inceptionYear.equals( that.inceptionYear ) : that.inceptionYear != null )
246 if ( projectDescription != null ? !projectDescription.equals( that.projectDescription )
247 : that.projectDescription != null )
255 public int hashCode()
257 int result = super.hashCode();
258 result = 31 * result + ( sha1Checksum != null ? sha1Checksum.hashCode() : 0 );
259 result = 31 * result + groupId.hashCode();
260 result = 31 * result + artifactId.hashCode();
261 result = 31 * result + version.hashCode();
262 result = 31 * result + baseVersion.hashCode();
263 result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
264 result = 31 * result + ( type != null ? type.hashCode() : 0 );
265 result = 31 * result + ( files != null ? files.hashCode() : 0 );
266 result = 31 * result + ( developers != null ? developers.hashCode() : 0 );
268 if ( dependencies != null )
270 List sorted = new ArrayList( dependencies );
271 Collections.sort( sorted );
273 result = 31 * result + sorted.hashCode();
276 result = 31 * result + ( repository != null ? repository.hashCode() : 0 );
277 result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
278 result = 31 * result + ( pluginPrefix != null ? pluginPrefix.hashCode() : 0 );
279 result = 31 * result + ( inceptionYear != null ? inceptionYear.hashCode() : 0 );
280 result = 31 * result + ( projectName != null ? projectName.hashCode() : 0 );
281 result = 31 * result + ( projectDescription != null ? projectDescription.hashCode() : 0 );
285 public String getSha1Checksum()
290 public String getGroupId()
295 public String getArtifactId()
300 public String getVersion()
305 public String getClassifier()
310 public String getType()
315 public List getFiles()
320 public String getRepository()
325 public String getPackaging()
330 public String getPluginPrefix()
335 public void setPackaging( String packaging )
337 this.packaging = packaging;
340 public void setPluginPrefix( String pluginPrefix )
342 this.pluginPrefix = pluginPrefix;
345 public void setInceptionYear( String inceptionYear )
347 this.inceptionYear = inceptionYear;
350 public void setProjectDescription( String description )
352 this.projectDescription = description;
355 public void setProjectName( String projectName )
357 this.projectName = projectName;
360 public String getInceptionYear()
362 return inceptionYear;
365 public String getProjectDescription()
367 return projectDescription;
370 public String getProjectName()
375 public void setBaseVersion( String baseVersion )
377 this.baseVersion = baseVersion;
380 public String getBaseVersion()
385 public void setDependencies( List dependencies )
387 this.dependencies = dependencies;
390 public void setDevelopers( List developers )
392 this.developers = developers;
395 public List getDevelopers()
400 public List getDependencies()
405 public String getPrimaryKey()
407 return groupId + ":" + artifactId + ":" + version + ( classifier != null ? ":" + classifier : "" );