Revision: 17811
          http://sourceforge.net/p/gate/code/17811
Author:   markagreenwood
Date:     2014-04-11 12:38:20 +0000 (Fri, 11 Apr 2014)
Log Message:
-----------
fixed the broken equals method

Modified Paths:
--------------
    gate/trunk/src/main/gate/jape/constraint/AnnotationFeatureAccessor.java

Modified: 
gate/trunk/src/main/gate/jape/constraint/AnnotationFeatureAccessor.java
===================================================================
--- gate/trunk/src/main/gate/jape/constraint/AnnotationFeatureAccessor.java     
2014-04-11 12:27:15 UTC (rev 17810)
+++ gate/trunk/src/main/gate/jape/constraint/AnnotationFeatureAccessor.java     
2014-04-11 12:38:20 UTC (rev 17811)
@@ -53,20 +53,23 @@
 
   @Override
   public int hashCode() {
-    return 37 + (featureName != null ? featureName.hashCode() : 0);
+    final int prime = 31;
+    int result = 1;
+    result =
+            prime * result
+                    + ((featureName == null) ? 0 : featureName.hashCode());
+    return result;
   }
 
   @Override
   public boolean equals(Object obj) {
+    if(this == obj) return true;
     if(obj == null) return false;
-    if(obj == this) return true;
-    if(!(this.getClass().equals(obj.getClass()))) return false;
-
-    AnnotationFeatureAccessor a = (AnnotationFeatureAccessor)obj;
-
-    if(featureName != a.getKey() && featureName != null
-            && !a.equals(a.getKey())) return false;
-
+    if(getClass() != obj.getClass()) return false;
+    AnnotationFeatureAccessor other = (AnnotationFeatureAccessor)obj;
+    if(featureName == null) {
+      if(other.featureName != null) return false;
+    } else if(!featureName.equals(other.featureName)) return false;
     return true;
   }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to