@Test public void shouldConsiderANodeToHaveSameAncestorAsItself() { assertThat(path.hasSameAncestor(path), is(true)); }
@Override public boolean hasSameAncestor( Path that ) { CheckArg.isNotNull(that, "that"); if (that.size() != this.size()) return false; if (this.size() == 1) return true; for (int i = this.size() - 2; i >= 0; --i) { Path.Segment thisSegment = this.getSegment(i); Path.Segment thatSegment = that.getSegment(i); if (!thisSegment.equals(thatSegment)) return false; } return true; }
AbstractPath implements Path { @Override public boolean hasSameAncestor( Path that ) { CheckArg.isNotNull(that, "that"); if (that.size() != this.size()) return false; if (this.size() == 1) return true; for (int i = this.size() - 2; i >= 0; --i) { Path.Segment thisSegment = this.getSegment(i); Path.Segment thatSegment = that.getSegment(i); if (!thisSegment.equals(thatSegment)) return false; } return true; } }
AbstractPath implements Path { @Override public boolean hasSameAncestor( Path that ) { CheckArg.isNotNull(that, "that"); if (that.size() != this.size()) return false; if (this.size() == 1) return true; for (int i = this.size() - 2; i >= 0; --i) { Path.Segment thisSegment = this.getSegment(i); Path.Segment thatSegment = that.getSegment(i); if (!thisSegment.equals(thatSegment)) return false; } return true; }  }
AbstractPath implements Path { @Override public boolean hasSameAncestor( Path that ) { CheckArg.isNotNull(that, "that"); if (that.size() != this.size()) return false; if (this.size() == 1) return true; for (int i = this.size() - 2; i >= 0; --i) { Path.Segment thisSegment = this.getSegment(i); Path.Segment thatSegment = that.getSegment(i); if (!thisSegment.equals(thatSegment)) return false; } return true; }  @Override boolean isIdentifier(); @Override Path getCanonicalPath(); @Override Path getCommonAncestor( Path that ); @Override Path.Segment getLastSegment(); @Override boolean endsWith( Name nameOfLastSegment ); @Override boolean endsWith( Name nameOfLastSegment,
                             int snsIndex ); @Override Path getParent(); @Override Segment getSegment( int index ); @Override Segment[] getSegmentsArray(); @Override Path getNormalizedPath(); @Override String getString(); @Override String getString( TextEncoder encoder ); @Override String getString( NamespaceRegistry namespaceRegistry ); @Override String getString( NamespaceRegistry namespaceRegistry,
                             TextEncoder encoder ); @Override String getString( NamespaceRegistry namespaceRegistry,
                             TextEncoder encoder,
                             TextEncoder delimiterEncoder ); @Override boolean hasSameAncestor( Path that ); @Override boolean isAncestorOf( Path descendant ); @Override boolean isAtOrBelow( Path other ); @Override boolean isAtOrAbove( Path other ); @Override boolean isDescendantOf( Path ancestor ); @Override boolean isSameAs( Path other ); @Override Iterator<Segment> iterator(); @Override Iterator<Path> pathsFromRoot(); @Override Path relativeToRoot(); @Override Path relativeTo( Path startingPath ); @Override Path resolve( Path relativePath ); @Override Path resolveAgainst( Path absolutePath ); @Override Path subpath( int beginIndex ); @Override Path subpath( int beginIndex,
                         int endIndex ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( Path that ); @Override String toString(); }
AbstractPath implements Path { @Override public boolean hasSameAncestor( Path that ) { CheckArg.isNotNull(that, "that"); if (that.size() != this.size()) return false; if (this.size() == 1) return true; for (int i = this.size() - 2; i >= 0; --i) { Path.Segment thisSegment = this.getSegment(i); Path.Segment thatSegment = that.getSegment(i); if (!thisSegment.equals(thatSegment)) return false; } return true; }  @Override boolean isIdentifier(); @Override Path getCanonicalPath(); @Override Path getCommonAncestor( Path that ); @Override Path.Segment getLastSegment(); @Override boolean endsWith( Name nameOfLastSegment ); @Override boolean endsWith( Name nameOfLastSegment,
                             int snsIndex ); @Override Path getParent(); @Override Segment getSegment( int index ); @Override Segment[] getSegmentsArray(); @Override Path getNormalizedPath(); @Override String getString(); @Override String getString( TextEncoder encoder ); @Override String getString( NamespaceRegistry namespaceRegistry ); @Override String getString( NamespaceRegistry namespaceRegistry,
                             TextEncoder encoder ); @Override String getString( NamespaceRegistry namespaceRegistry,
                             TextEncoder encoder,
                             TextEncoder delimiterEncoder ); @Override boolean hasSameAncestor( Path that ); @Override boolean isAncestorOf( Path descendant ); @Override boolean isAtOrBelow( Path other ); @Override boolean isAtOrAbove( Path other ); @Override boolean isDescendantOf( Path ancestor ); @Override boolean isSameAs( Path other ); @Override Iterator<Segment> iterator(); @Override Iterator<Path> pathsFromRoot(); @Override Path relativeToRoot(); @Override Path relativeTo( Path startingPath ); @Override Path resolve( Path relativePath ); @Override Path resolveAgainst( Path absolutePath ); @Override Path subpath( int beginIndex ); @Override Path subpath( int beginIndex,
                         int endIndex ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( Path that ); @Override String toString(); static final Path SELF_PATH; }