public UniformItemPath clone() { UniformItemPathImpl clone = new UniformItemPathImpl(); for (ItemPathSegment segment : segments) { clone.segments.add(segment.clone()); } if (namespaceMap != null) { clone.namespaceMap = new HashMap<>(namespaceMap); } return clone; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; IdItemPathSegment other = (IdItemPathSegment) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); // this version is for "precise" equals result = prime * result + name.hashCode(); return result; }
public boolean equals(Object obj, boolean allowUnqualified, boolean allowDifferentPrefixes) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } VariableItemPathSegment other = (VariableItemPathSegment) obj; if (allowUnqualified) { if (!allowDifferentPrefixes) { throw new UnsupportedOperationException("It is not possible to disallow different prefixes while allowing unqualified names"); } return QNameUtil.match(name, other.name); } else { if (!name.equals(other.name)) { // compares namespace and local part return false; } // in order to differentiate between x:name and name (when x is undefined) we will compare the prefixes as well if (!allowDifferentPrefixes && !normalizedPrefix(name).equals(normalizedPrefix(other.name))) { return false; } return true; } }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); // if we need to compute hash from namespace-normalized name, we would use this one: // (in order for equals to work; if we decide to change equals in such a way later) // result = prime * result + ((name == null) ? 0 : name.getLocalPart().hashCode()); // this version is for "precise" equals result = prime * result + name.hashCode(); return result; }
public boolean equals(Object obj, boolean allowUnqualified, boolean allowDifferentPrefixes) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } NameItemPathSegment other = (NameItemPathSegment) obj; if (allowUnqualified) { if (!allowDifferentPrefixes) { throw new UnsupportedOperationException("It is not possible to disallow different prefixes while allowing unqualified names"); } return QNameUtil.match(name, other.name); } else { if (!name.equals(other.name)) { // compares namespace and local part return false; } // in order to differentiate between x:name and name (when x is undefined) we will compare the prefixes as well if (!allowDifferentPrefixes && !normalizedPrefix(name).equals(normalizedPrefix(other.name))) { return false; } return true; } }