Author: vsiveton
Date: Fri Jan 4 04:35:09 2008
New Revision: 608815
URL: http://svn.apache.org/viewvc?rev=608815&view=rev
Log:
MNG-3318: ActiveProjectArtifact should have appropriate equals and hashCode
methods
o added equals() and hashcode() like DefaultArtifact
Modified:
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java
Modified:
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java?rev=608815&r1=608814&r2=608815&view=diff
==============================================================================
---
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java
(original)
+++
maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java
Fri Jan 4 04:35:09 2008
@@ -296,4 +296,64 @@
{
artifact.setOptional( optional );
}
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public int hashCode()
+ {
+ int result = 17;
+
+ result = 37 * result + getGroupId().hashCode();
+ result = 37 * result + getArtifactId().hashCode();
+ result = 37 * result + getType().hashCode();
+ if ( getVersion() != null )
+ {
+ result = 37 * result + getVersion().hashCode();
+ }
+ result = 37 * result + ( getClassifier() != null ?
getClassifier().hashCode() : 0 );
+
+ return result;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ */
+ public boolean equals( Object o )
+ {
+ if ( o == this )
+ {
+ return true;
+ }
+
+ if ( !( o instanceof Artifact ) )
+ {
+ return false;
+ }
+
+ Artifact a = (Artifact) o;
+
+ if ( !a.getGroupId().equals( getGroupId() ) )
+ {
+ return false;
+ }
+ else if ( !a.getArtifactId().equals( getArtifactId() ) )
+ {
+ return false;
+ }
+ else if ( !a.getVersion().equals( getVersion() ) )
+ {
+ return false;
+ }
+ else if ( !a.getType().equals( getType() ) )
+ {
+ return false;
+ }
+ else if ( a.getClassifier() == null ? getClassifier() != null :
!a.getClassifier().equals( getClassifier() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
}