wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r817656 - /incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java
Date Tue, 22 Sep 2009 13:30:04 GMT
Author: elman
Date: Tue Sep 22 13:30:04 2009
New Revision: 817656

URL: http://svn.apache.org/viewvc?rev=817656&view=rev
Log:
small bug: overriding equals() requires overriding hashCode().

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java?rev=817656&r1=817655&r2=817656&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java
Tue Sep 22 13:30:04 2009
@@ -207,18 +207,45 @@
         return resultStr;
     }
 
-    @Override
-    public boolean equals(Object obj) {
-        return obj instanceof UriTemplateProcessor && template
-            .equals(((UriTemplateProcessor)obj).template);
-    }
+//    @Override
+//    public boolean equals(Object obj) {
+//        return obj instanceof UriTemplateProcessor && template
+//            .equals(((UriTemplateProcessor)obj).template);
+//    }
 
+    
+    
     @Override
     public String toString() {
         return template;
     }
 
     @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((template == null) ? 0 : template.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        UriTemplateProcessor other = (UriTemplateProcessor)obj;
+        if (template == null) {
+            if (other.template != null)
+                return false;
+        } else if (!template.equals(other.template))
+            return false;
+        return true;
+    }
+
+    @Override
     public UriTemplateProcessor clone() {
         try {
             UriTemplateProcessor ret = (UriTemplateProcessor)super.clone();



Mime
View raw message