Path implements CacheValue, Comparable<Path> { public boolean isAncestorOf(@NotNull Path other) { checkNotNull(other); int depthDiff = other.getDepth() - getDepth(); return depthDiff > 0 && elementsEqual(elements(true), other.getAncestor(depthDiff).elements(true)); } private  Path(@Nullable Path parent,
                 @NotNull String name,
                 int hash);  Path(@NotNull Path parent, @NotNull String name);  Path(@NotNull String name); @NotNull String getName(); @NotNull Iterable<String> elements(); boolean isRoot(); @Nullable Path getParent(); int length(); int getDepth(); @NotNull Path getAncestor(int nth); boolean isAncestorOf(@NotNull Path other); boolean isAbsolute(); @NotNull static Path fromString(@NotNull String path); @NotNull StringBuilder toStringBuilder(@NotNull StringBuilder sb); @Override int getMemory(); @Override int compareTo(@NotNull Path other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final Path ROOT; }
@Test public void isAncestorOf() { assertTrue(root.isAncestorOf(foo)); assertTrue(root.isAncestorOf(fooBar)); assertTrue(foo.isAncestorOf(fooBar)); assertTrue(fooBar.isAncestorOf(fooBarQuux)); assertFalse(root.isAncestorOf(root)); assertFalse(foo.isAncestorOf(root)); assertFalse(foo.isAncestorOf(foo)); assertFalse(fooBar.isAncestorOf(fooBar)); assertFalse(fooBar.isAncestorOf(foo)); assertFalse(fooBar.isAncestorOf(root)); assertFalse(root.isAncestorOf(relFoo)); assertFalse(root.isAncestorOf(relFooBar)); assertFalse(relFoo.isAncestorOf(relFoo)); assertFalse(relFooBar.isAncestorOf(relFoo)); assertFalse(relFooBar.isAncestorOf(relFooBar)); assertFalse(relFooBarQuux.isAncestorOf(relFooBar)); assertFalse(relFooBarQuux.isAncestorOf(relFooBarQuux)); assertTrue(relFoo.isAncestorOf(relFooBar)); assertTrue(relFooBar.isAncestorOf(relFooBarQuux)); assertFalse(foo.isAncestorOf(relFooBar)); assertFalse(foo.isAncestorOf(relFooBarQuux)); assertFalse(relFoo.isAncestorOf(fooBar)); assertFalse(relFoo.isAncestorOf(fooBarQuux)); }