You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/01/21 06:11:51 UTC

[groovy] branch GROOVY_4_0_X updated (97ed4a1 -> 71e84d4)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 97ed4a1  GROOVY-7033: slight tweak to test (check TYPE_USE case also)
     new 79193d6  GROOVY-10463: Add equals() and hashCode() methods to ImportNode
     new 71e84d4  GROOVY-10463: Add equals() and hashCode() methods to ImportNode (fix hashCode caching)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/codehaus/groovy/ast/ImportNode.java   | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)

[groovy] 02/02: GROOVY-10463: Add equals() and hashCode() methods to ImportNode (fix hashCode caching)

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 71e84d48e6879b6905ded1b47106cbb10870d556
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Jan 21 16:10:57 2022 +1000

    GROOVY-10463: Add equals() and hashCode() methods to ImportNode (fix hashCode caching)
---
 src/main/java/org/codehaus/groovy/ast/ImportNode.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/codehaus/groovy/ast/ImportNode.java b/src/main/java/org/codehaus/groovy/ast/ImportNode.java
index af31d40..d72bc23 100644
--- a/src/main/java/org/codehaus/groovy/ast/ImportNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ImportNode.java
@@ -146,6 +146,7 @@ public class ImportNode extends AnnotatedNode {
 
     public void setType(final ClassNode type) {
         this.type = type;
+        hashCode = 0;
     }
 
     @Override

[groovy] 01/02: GROOVY-10463: Add equals() and hashCode() methods to ImportNode

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 79193d6721d389cbf550898809c44bac152010d7
Author: tmoore <tm...@spatial.ca>
AuthorDate: Tue Jan 4 14:58:55 2022 -0500

    GROOVY-10463: Add equals() and hashCode() methods to ImportNode
---
 .../java/org/codehaus/groovy/ast/ImportNode.java   | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/ast/ImportNode.java b/src/main/java/org/codehaus/groovy/ast/ImportNode.java
index 406788f..af31d40 100644
--- a/src/main/java/org/codehaus/groovy/ast/ImportNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ImportNode.java
@@ -31,6 +31,7 @@ public class ImportNode extends AnnotatedNode {
     private final String packageName;
     private final boolean isStar;
     private final boolean isStatic;
+    private int hashCode;
 
     /**
      * An import of a single type, i.e.&#160;{@code import pack.Type} or {@code import pack.Type as Alias}
@@ -148,6 +149,53 @@ public class ImportNode extends AnnotatedNode {
     }
 
     @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof ImportNode))
+            return false;
+        ImportNode imp = (ImportNode) o;
+        if ((type == null) != (imp.type == null))
+            return false;
+        if (type != null && !type.equals(imp.type))
+            return false;
+        if ((alias == null) != (imp.alias == null))
+            return false;
+        if (alias != null && !alias.equals(imp.alias))
+            return false;
+        if ((fieldName == null) != (imp.fieldName == null))
+            return false;
+        if (fieldName != null && !fieldName.equals(imp.fieldName))
+            return false;
+        if ((packageName == null) != (imp.packageName == null))
+            return false;
+        if (packageName != null && !packageName.equals(imp.packageName))
+            return false;
+        if (isStar != imp.isStar)
+            return false;
+        if (isStatic != imp.isStatic)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = hashCode;
+        if (result == 0) {
+            if (type != null)
+                result = 31 * result + type.hashCode();
+            if (alias != null)
+                result = 31 * result + alias.hashCode();
+            if (fieldName != null)
+                result = 31 * result + fieldName.hashCode();
+            if (packageName != null)
+                result = 31 * result + packageName.hashCode();
+            result = 31 * result +Boolean.hashCode(isStar);
+            result = 31 * result +Boolean.hashCode(isStatic);
+            hashCode = result;
+        }
+        return result;
+    }
+
+    @Override
     public void visit(final GroovyCodeVisitor visitor) {
     }
 }