From cde6ccd6fcdd6a85d60f1ed375e533ea1da610c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Hall=C3=A9?= Date: Thu, 21 Jul 2016 10:15:09 -0400 Subject: [PATCH] Implemented hashCode --- .../Core/src/ca/uqac/lif/xml/TextElement.java | 16 ++++++++++++++ .../Core/src/ca/uqac/lif/xml/XmlElement.java | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Source/Core/src/ca/uqac/lif/xml/TextElement.java b/Source/Core/src/ca/uqac/lif/xml/TextElement.java index cefbe0d..b386dca 100755 --- a/Source/Core/src/ca/uqac/lif/xml/TextElement.java +++ b/Source/Core/src/ca/uqac/lif/xml/TextElement.java @@ -49,4 +49,20 @@ public String toString() { return m_text; } + + @Override + public int hashCode() + { + return m_text.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !(o instanceof TextElement)) + { + return false; + } + return m_text.compareTo(((TextElement) o).m_text) == 0; + } } diff --git a/Source/Core/src/ca/uqac/lif/xml/XmlElement.java b/Source/Core/src/ca/uqac/lif/xml/XmlElement.java index 15d021b..669dcf0 100755 --- a/Source/Core/src/ca/uqac/lif/xml/XmlElement.java +++ b/Source/Core/src/ca/uqac/lif/xml/XmlElement.java @@ -224,4 +224,25 @@ public XmlParseException(String message) } return null; } + + @Override + public int hashCode() + { + return m_name.hashCode(); + } + + @Override + public boolean equals(Object o) + { + if (o == null || !(o instanceof XmlElement)) + { + return false; + } + XmlElement xe = (XmlElement) o; + if (m_children.size() != xe.m_children.size()) + { + return false; + } + return m_children.containsAll(xe.m_children); + } }