From 160c9114994a35d48e79b8ceb6ca30263a96793f Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 29 Apr 2012 23:32:47 +0200 Subject: [PATCH] fix android test: more precise DomChildrenDescription.equals/hashCode --- .../impl/AbstractDomChildDescriptionImpl.java | 23 +++++++++++++++++++ .../xml/impl/DomChildDescriptionImpl.java | 8 +++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java index 95c1b04ff6fc..186e810c2fe7 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java @@ -62,6 +62,29 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil myCustomAnnotations.put(annotation.annotationType(), annotation); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + AbstractDomChildDescriptionImpl that = (AbstractDomChildDescriptionImpl)o; + + if (myCustomAnnotations != null ? !myCustomAnnotations.equals(that.myCustomAnnotations) : that.myCustomAnnotations != null) + return false; + if (!myType.equals(that.myType)) return false; + if (myUserMap != null ? !myUserMap.equals(that.myUserMap) : that.myUserMap != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = myType.hashCode(); + result = 31 * result + (myCustomAnnotations != null ? myCustomAnnotations.hashCode() : 0); + result = 31 * result + (myUserMap != null ? myUserMap.hashCode() : 0); + return result; + } + public void setUserMap(final Map userMap) { myUserMap = userMap; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java index 0a604c4811b5..108e1e1a5685 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java @@ -39,20 +39,18 @@ public abstract class DomChildDescriptionImpl extends AbstractDomChildDescriptio public boolean equals(final Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; final DomChildDescriptionImpl that = (DomChildDescriptionImpl)o; if (myTagName != null ? !myTagName.equals(that.myTagName) : that.myTagName != null) return false; - if (!getType().equals(that.getType())) return false; return true; } public int hashCode() { - int result; - result = (myTagName != null ? myTagName.hashCode() : 0); - result = 31 * result + getType().hashCode(); + int result = super.hashCode(); + result = 31 * result + (myTagName != null ? myTagName.hashCode() : 0); return result; }