AbstractPath implements Path { @Override public boolean isDescendantOf( Path ancestor ) { CheckArg.isNotNull(ancestor, "ancestor"); if (this == ancestor) return false; if (ancestor.isRoot()) return true; if (ancestor.size() >= this.size()) return false; Path thisPath = this.getAncestor(this.size() - ancestor.size()); Path thatPath = ancestor; assert thisPath.size() == thatPath.size(); while (!thisPath.isRoot() && thisPath.getLastSegment().equals(thatPath.getLastSegment())) { thisPath = thisPath.getParent(); thatPath = thatPath.getParent(); } return thisPath.isRoot(); }  @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; }
@Test public void shouldNotConsiderNodeToBeDecendantOfItself() { assertThat(path.isDescendantOf(path), is(false)); }
@Test( expected = IllegalArgumentException.class ) public void shouldFailForDecendantOfNullPath() { path.isDescendantOf(null); }