groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Refine GPathResult's equals and hashCode
Date Tue, 05 Dec 2017 07:22:28 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X da453caa8 -> 4ed4d88ae


Refine GPathResult's equals and hashCode

(cherry picked from commit be099d3)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4ed4d88a
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4ed4d88a
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4ed4d88a

Branch: refs/heads/GROOVY_2_5_X
Commit: 4ed4d88ae2141ba00a0ee2281f322a5f30329f95
Parents: da453ca
Author: sunlan <sunlan@apache.org>
Authored: Tue Dec 5 15:05:19 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Dec 5 15:22:23 2017 +0800

----------------------------------------------------------------------
 .../groovy/util/slurpersupport/GPathResult.java     | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/4ed4d88a/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
b/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
index 5aca4b6..f4d0c54 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
@@ -43,6 +43,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Stack;
 
 /**
@@ -369,11 +370,18 @@ public abstract class GPathResult extends GroovyObjectSupport implements
Writabl
         return this;
     }
 
-    /* (non-Javadoc)
-    * @see java.lang.Object#equals(java.lang.Object)
-    */
+    @Override
+    public int hashCode() {
+        return Objects.hash(text());
+    }
+
+    @Override
     public boolean equals(Object obj) {
-        return text().equals(obj.toString());
+        if (!(obj instanceof GPathResult)) {
+            return false;
+        }
+
+        return text().equals(((GPathResult) obj).text());
     }
 
     /**


Mime
View raw message