From d5460f52cc03384f6baea054e8209654d09b81ee Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 15 Mar 2005 13:18:45 +0000 Subject: [PATCH] add equals and hashcode to Location git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277966 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/Location.java | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/Location.java b/src/main/org/apache/tools/ant/Location.java index 247279ec5..a54b39577 100644 --- a/src/main/org/apache/tools/ant/Location.java +++ b/src/main/org/apache/tools/ant/Location.java @@ -117,7 +117,7 @@ public class Location implements Serializable { public int getColumnNumber() { return columnNumber; } - + /** * Returns the file name, line number, a colon and a trailing space. * An error message can be appended easily. For unknown locations, an @@ -145,4 +145,30 @@ public class Location implements Serializable { return buf.toString(); } + /** + * Equality operation. + * @param other the object to compare to. + * @return true if the other object contains the same information + * as this object. + */ + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + if (!(other.getClass() == getClass())) { + return false; + } + return toString().equals(other.toString()); + } + + /** + * Hash operation. + * @return a hash code value for this location. + */ + public int hashCode() { + return toString().hashCode(); + } }