Path implements CacheValue, Comparable<Path> { public int length() { if (isRoot()) { return 1; } int length = 0; Path p = this; while (p != null) { length += p.name.length(); if (p.parent != null) { length++; } p = p.parent; } return length; } 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 length() { assertEquals(root.toString().length(), root.length()); assertEquals(foo.toString().length(), foo.length()); assertEquals(fooBar.toString().length(), fooBar.length()); assertEquals(fooBarQuux.toString().length(), fooBarQuux.length()); assertEquals(relFoo.toString().length(), relFoo.length()); assertEquals(relFooBar.toString().length(), relFooBar.length()); assertEquals(relFooBarQuux.toString().length(), relFooBarQuux.length()); }