public boolean equals()

in nbxml/src/main/java/org/apache/vysper/xml/fragment/XMLElement.java [304:343]


    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || !(o instanceof XMLElement))
            return false;

        final XMLElement that = (XMLElement) o;

        // attributes are allowed to be in any order
        if(attributes != null && that.attributes != null) {
            if(attributes.size() != that.attributes.size()) return false;
            for(Attribute attribute : attributes) {
                boolean found = false;
                for(Attribute thatAttribute : that.attributes) {
                    if(thatAttribute.equals(attribute)) {
                        found = true;
                        break;
                    }
                }
                if(!found) return false;
            }
            
        } else if(attributes == null && that.attributes == null) {
            // ok
        } else {
            return false;
        }
        
        if (innerFragments != null ? !innerFragments.equals(that.innerFragments) : that.innerFragments != null) {
            return false;
        }
        if (name != null ? !name.equals(that.name) : that.name != null)
            return false;

        // TODO the namespace prefix should not matter for equality, only the URI
        if (namespacePrefix != null ? !namespacePrefix.equals(that.namespacePrefix) : that.namespacePrefix != null)
            return false;

        return true;
    }