Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2017-11-20 16:52:31 -0500
committerTill Brychcy2018-01-19 02:37:45 -0500
commit8e6858e858b81430059914da5f4189ae96c32222 (patch)
treebcea6e276c6b590992b84a120aeaa314c08a75d8 /org.eclipse.jdt.compiler.apt
parente43f23d48deef5531e69570ea52565614eac5e0c (diff)
downloadeclipse.jdt.core-8e6858e858b81430059914da5f4189ae96c32222.tar.gz
eclipse.jdt.core-8e6858e858b81430059914da5f4189ae96c32222.tar.xz
eclipse.jdt.core-8e6858e858b81430059914da5f4189ae96c32222.zip
Bug 527530 - Fix hashCode and equals for VariableElementImpl
Diffstat (limited to 'org.eclipse.jdt.compiler.apt')
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java13
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java37
2 files changed, 50 insertions, 0 deletions
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
index 862e278aa0..f91af9f86f 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/VariableElementImpl.java
@@ -14,6 +14,7 @@ package org.eclipse.jdt.internal.compiler.apt.model;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import javax.lang.model.element.Element;
@@ -179,4 +180,16 @@ public class VariableElementImpl extends ElementImpl implements VariableElement
public String toString() {
return new String(((VariableBinding) _binding).name);
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final VariableElementImpl other = (VariableElementImpl) obj;
+ return Objects.equals(this._binding, other._binding);
+ }
}
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
index 53315f5852..b1effcae09 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/lookup/AptBinaryLocalVariableBinding.java
@@ -10,6 +10,11 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public class AptBinaryLocalVariableBinding extends LocalVariableBinding {
AnnotationBinding[] annotationBindings;
// enclosing element
@@ -24,4 +29,36 @@ public class AptBinaryLocalVariableBinding extends LocalVariableBinding {
public AnnotationBinding[] getAnnotations() {
return this.annotationBindings;
}
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ int c = CharOperation.hashCode(name);
+ result = 31 * result + c;
+ c = this.type.hashCode();
+ result = 31 * result + c;
+ c = modifiers;
+ result = 31 * result + c;
+ c = Arrays.hashCode(this.annotationBindings);
+ result = 31 * result + c;
+ c = methodBinding.hashCode();
+ result = 31 * result + c;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AptBinaryLocalVariableBinding other = (AptBinaryLocalVariableBinding) obj;
+ return CharOperation.equals(this.name, other.name)
+ && Objects.equals(this.type, other.type)
+ && modifiers==other.modifiers
+ && Arrays.equals(this.annotationBindings, other.annotationBindings)
+ && Objects.equals(this.methodBinding, other.methodBinding);
+ }
}

Back to the top