abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r442256 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
Date Mon, 11 Sep 2006 17:03:29 GMT
Author: jmsnell
Date: Mon Sep 11 10:03:28 2006
New Revision: 442256

URL: http://svn.apache.org/viewvc?view=rev&rev=442256
Log:
Properly implement equals and hashCode for RegexTargetResolver

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java?view=diff&rev=442256&r1=442255&r2=442256
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
Mon Sep 11 10:03:28 2006
@@ -132,6 +132,48 @@
        matcher = pattern.matcher(v);
        matcher.matches();
     }
+
+    @Override
+    public int hashCode() {
+      final int PRIME = 31;
+      int result = 1;
+      String m = matcher.group(0);
+      String p = matcher.pattern().pattern();
+      result = PRIME * result + ((m == null) ? 0 : m.hashCode());
+      result = PRIME * result + ((p == null) ? 0 : p.hashCode());
+      result = PRIME * result + ((type == null) ? 0 : type.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;
+      final RegexTarget other = (RegexTarget) obj;
+      String m = matcher.group(0);
+      String p = matcher.pattern().pattern();
+      String m2 = other.matcher.group(0);
+      String p2 = other.matcher.pattern().pattern();
+      if (m == null) {
+        if (m2 != null)
+          return false;
+      } else if (!m.equals(m2))
+        return false;
+      if (p == null) {
+        if (p2 != null)
+          return false;
+      } else if (!p.equals(p2))
+        return false;
+      if (type == null) {
+        if (other.type != null)
+          return false;
+      } else if (!type.equals(other.type))
+        return false;
+      return true;
+    }
+    
+    
   }
   
 }



Mime
View raw message