ElementImpl extends NodeImpl implements Element { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ElementImpl)) return false; ElementImpl other = (ElementImpl) obj; if (!attributes.equals(other.attributes)) return false; if (!name.equals(other.name)) return false; if (!namespaceUri.equals(other.namespaceUri)) return false; if (!getChildren().equals(other.getChildren())) return false; return true; } protected  ElementImpl(String namespaceUri, String prefix, String name); protected  ElementImpl(String namespaceUri, String name,
			org.w3c.dom.Element xmlElement); String getNamespaceUri(); String getPrefix(); String getName(); Map<String, String> getNamespacePrefixMapping(); void setNamespacePrefixMapping(Map<String, String> namespace2Prefix); Collection<? extends Attribute> getAttributes(); abstract List<? extends Node> getChildren(); org.w3c.dom.Element asXmlNode(Document document); Object clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEqualsObjectSimple() { ConcreteElementImpl elem1 = new ConcreteElementImpl("ns", "pre", "name"); ConcreteElementImpl elem2 = new ConcreteElementImpl("ns", "pre2", "name"); ConcreteElementImpl elem3 = new ConcreteElementImpl("ns", null, "name"); ConcreteElementImpl elem4 = new ConcreteElementImpl("ns2", "pre2", "name"); ConcreteElementImpl elem5 = new ConcreteElementImpl("ns", "pre2", "name2"); assertEquals(elem1, elem1); assertEquals(elem1, elem2); assertEquals(elem1, elem3); assertFalse(elem1.equals(elem4)); assertFalse(elem1.equals(elem5)); assertFalse(elem1.equals(null)); assertFalse(elem1.equals(new Object())); }
@Test public void testEqualsObjectChildren() { ConcreteElementImpl elem1 = new ConcreteElementImpl("ns", null, "name"); ConcreteElementImpl elem2 = new ConcreteElementImpl("ns", null, "name"); ConcreteElementImpl elem3 = new ConcreteElementImpl("ns", null, "name"); ConcreteElementImpl elem4 = new ConcreteElementImpl("ns", null, "name"); elem1.addChild(new ConcreteElementImpl("ns", null, "name")); elem2.addChild(new ConcreteElementImpl("ns", null, "name")); elem3.addChild(new ConcreteElementImpl("ns", null, "name")); elem3.addChild(new ConcreteElementImpl("ns", null, "name")); elem4.addChild(new TextImpl("abc")); assertEquals(elem1, elem2); assertFalse(elem1.equals(elem3)); assertFalse(elem1.equals(elem4)); }