geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r381701 - /geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java
Date Tue, 28 Feb 2006 16:50:24 GMT
Author: djencks
Date: Tue Feb 28 08:50:21 2006
New Revision: 381701

URL: http://svn.apache.org/viewcvs?rev=381701&view=rev
Log:
GERONIMO-1661 implement equals and hashCode on Version class.

Modified:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java?rev=381701&r1=381700&r2=381701&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Version.java
Tue Feb 28 08:50:21 2006
@@ -207,4 +207,47 @@
         }
         return buf.toString();
     }
+
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (this.getClass() != other.getClass()) {
+            return false;
+        }
+        Version v = (Version) other;
+        if (majorVersion == null? v.majorVersion != null: !majorVersion.equals(v.majorVersion))
{
+            return false;
+        }
+        if (minorVersion == null? v.minorVersion != null: !minorVersion.equals(v.minorVersion))
{
+            return false;
+        }
+        if (incrementalVersion == null? v.incrementalVersion != null: !incrementalVersion.equals(v.incrementalVersion))
{
+            return false;
+        }
+        if (buildNumber == null? v.buildNumber != null: !buildNumber.equals(v.buildNumber))
{
+            return false;
+        }
+        return qualifier == null ? v.qualifier == null : qualifier.equals(v.qualifier);
+    }
+
+    public int hashCode() {
+        int hashCode = 0;
+        if (majorVersion != null) {
+            hashCode = majorVersion.intValue();
+        }
+        if (minorVersion != null) {
+            hashCode = 37 * hashCode + minorVersion.intValue();
+        }
+        if (incrementalVersion != null) {
+            hashCode = 37 * hashCode + incrementalVersion.intValue();
+        }
+        if (buildNumber != null) {
+            hashCode = 37 * hashCode + buildNumber.intValue();
+        }
+        if (qualifier != null) {
+            hashCode = 37 * hashCode + qualifier.hashCode();
+        }
+        return hashCode;
+    }
 }



Mime
View raw message