1 package org.apache.maven.archiva.indexer.record;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
27 * The a record with the fields in the standard index.
29 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
31 public class StandardArtifactIndexRecord
32 extends MinimalArtifactIndexRecord
35 * The SHA-1 checksum of the artifact file.
37 private String sha1Checksum;
40 * The artifact's group.
42 private String groupId;
45 * The artifact's identifier within the group.
47 private String artifactId;
50 * The artifact's version.
52 private String version;
55 * The classifier, if there is one.
57 private String classifier;
60 * The artifact type (from the file).
65 * A list of files (separated by '\n') in the artifact if it is an archive.
70 * The identifier of the repository that the artifact came from.
72 private String repository;
75 * The packaging specified in the POM for this artifact.
77 private String packaging;
80 * The plugin prefix specified in the metadata if the artifact is a plugin.
82 private String pluginPrefix;
85 * The year the project was started.
87 private String inceptionYear;
90 * The description of the project.
92 private String projectDescription;
95 * The name of the project.
97 private String projectName;
100 * The base version (before the snapshot is determined).
102 private String baseVersion;
105 * A list of dependencies for the artifact, each a string of the form <code>groupId:artifactId:version</code>.
107 private List dependencies;
110 * A list of developers in the POM, each a string of the form <code>id:name:email</code>.
112 private List developers;
114 public void setSha1Checksum( String sha1Checksum )
116 this.sha1Checksum = sha1Checksum;
119 public void setGroupId( String groupId )
121 this.groupId = groupId;
124 public void setArtifactId( String artifactId )
126 this.artifactId = artifactId;
129 public void setVersion( String version )
131 this.version = version;
134 public void setClassifier( String classifier )
136 this.classifier = classifier;
139 public void setType( String type )
144 public void setFiles( List files )
149 public void setRepository( String repository )
151 this.repository = repository;
155 * @noinspection RedundantIfStatement
157 public boolean equals( Object obj )
163 if ( obj == null || getClass() != obj.getClass() )
167 if ( !super.equals( obj ) )
172 StandardArtifactIndexRecord that = (StandardArtifactIndexRecord) obj;
174 if ( !artifactId.equals( that.artifactId ) )
178 if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
183 if ( dependencies != null && that.dependencies != null )
185 List sorted = new ArrayList( dependencies );
186 Collections.sort( sorted );
188 List sortedOther = new ArrayList( that.dependencies );
189 Collections.sort( sortedOther );
191 if ( !sorted.equals( sortedOther ) )
196 else if ( !( dependencies == null && that.dependencies == null ) )
201 if ( developers != null ? !developers.equals( that.developers ) : that.developers != null )
205 if ( files != null ? !files.equals( that.files ) : that.files != null )
209 if ( !groupId.equals( that.groupId ) )
213 if ( repository != null ? !repository.equals( that.repository ) : that.repository != null )
217 if ( sha1Checksum != null ? !sha1Checksum.equals( that.sha1Checksum ) : that.sha1Checksum != null )
221 if ( type != null ? !type.equals( that.type ) : that.type != null )
225 if ( !version.equals( that.version ) )
229 if ( !baseVersion.equals( that.baseVersion ) )
233 if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null )
237 if ( pluginPrefix != null ? !pluginPrefix.equals( that.pluginPrefix ) : that.pluginPrefix != null )
241 if ( projectName != null ? !projectName.equals( that.projectName ) : that.projectName != null )
245 if ( inceptionYear != null ? !inceptionYear.equals( that.inceptionYear ) : that.inceptionYear != null )
249 if ( projectDescription != null ? !projectDescription.equals( that.projectDescription )
250 : that.projectDescription != null )
258 public int hashCode()
260 int result = super.hashCode();
261 result = 31 * result + ( sha1Checksum != null ? sha1Checksum.hashCode() : 0 );
262 result = 31 * result + groupId.hashCode();
263 result = 31 * result + artifactId.hashCode();
264 result = 31 * result + version.hashCode();
265 result = 31 * result + baseVersion.hashCode();
266 result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
267 result = 31 * result + ( type != null ? type.hashCode() : 0 );
268 result = 31 * result + ( files != null ? files.hashCode() : 0 );
269 result = 31 * result + ( developers != null ? developers.hashCode() : 0 );
271 if ( dependencies != null )
273 List sorted = new ArrayList( dependencies );
274 Collections.sort( sorted );
276 result = 31 * result + sorted.hashCode();
279 result = 31 * result + ( repository != null ? repository.hashCode() : 0 );
280 result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
281 result = 31 * result + ( pluginPrefix != null ? pluginPrefix.hashCode() : 0 );
282 result = 31 * result + ( inceptionYear != null ? inceptionYear.hashCode() : 0 );
283 result = 31 * result + ( projectName != null ? projectName.hashCode() : 0 );
284 result = 31 * result + ( projectDescription != null ? projectDescription.hashCode() : 0 );
288 public String getSha1Checksum()
293 public String getGroupId()
298 public String getArtifactId()
303 public String getVersion()
308 public String getClassifier()
313 public String getType()
318 public List getFiles()
323 public String getRepository()
328 public String getPackaging()
333 public String getPluginPrefix()
338 public void setPackaging( String packaging )
340 this.packaging = packaging;
343 public void setPluginPrefix( String pluginPrefix )
345 this.pluginPrefix = pluginPrefix;
348 public void setInceptionYear( String inceptionYear )
350 this.inceptionYear = inceptionYear;
353 public void setProjectDescription( String description )
355 this.projectDescription = description;
358 public void setProjectName( String projectName )
360 this.projectName = projectName;
363 public String getInceptionYear()
365 return inceptionYear;
368 public String getProjectDescription()
370 return projectDescription;
373 public String getProjectName()
378 public void setBaseVersion( String baseVersion )
380 this.baseVersion = baseVersion;
383 public String getBaseVersion()
388 public void setDependencies( List dependencies )
390 this.dependencies = dependencies;
393 public void setDevelopers( List developers )
395 this.developers = developers;
398 public List getDevelopers()
403 public List getDependencies()
408 public String getPrimaryKey()
410 return groupId + ":" + artifactId + ":" + version + ( classifier != null ? ":" + classifier : "" );