Index: Path.java =================================================================== --- Path.java (revision 517212) +++ Path.java (working copy) @@ -1194,9 +1194,8 @@ * @return hash code */ public int hashCode() { - // @todo treat index==0 as index==1? int h = 17; - h = 37 * h + index; + h = 37 * h + normalizeIndex(index); h = 37 * h + name.hashCode(); return h; } @@ -1216,13 +1215,23 @@ if (obj instanceof PathElement) { PathElement other = (PathElement) obj; return name.equals(other.name) - // @todo treat index==0 as index==1? - && index == other.index; + && normalizeIndex(index) == normalizeIndex(other.index); } return false; } /** + * Normalizes index value {@link Path#INDEX_UNDEFINED} to + * {@link Path#INDEX_DEFAULT} for {@link #equals(Object)} and + * {@link #hashCode()}. + * @param index + * @return normalized index + */ + private int normalizeIndex(int index) { + return index == Path.INDEX_UNDEFINED ? Path.INDEX_DEFAULT : index; + } + + /** * Returns true if this element denotes the root element, * otherwise returns false. *