Skip to content

Commit

Permalink
Implemented hashCode
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainhalle committed Jul 21, 2016
1 parent 5d6d33f commit cde6ccd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Source/Core/src/ca/uqac/lif/xml/TextElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
21 changes: 21 additions & 0 deletions Source/Core/src/ca/uqac/lif/xml/XmlElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit cde6ccd

Please sign in to comment.