Browse Source

add equals and hashcode to Location

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277966 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
d5460f52cc
1 changed files with 27 additions and 1 deletions
  1. +27
    -1
      src/main/org/apache/tools/ant/Location.java

+ 27
- 1
src/main/org/apache/tools/ant/Location.java View File

@@ -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();
}
}

Loading…
Cancel
Save