ImmutableListPathCore implements PathCore<ImmutableListPathCore> { @Override public String toPathString(String separator) { checkNotNull(separator, "separator must be non-null"); checkArgument(!separator.isEmpty(), "separator must be non-empty"); StringBuilder pathString = new StringBuilder(); if (isAbsolute()) { pathString.append(root).append(separator); } Joiner.on(separator).appendTo(pathString, path); return pathString.toString(); } ImmutableListPathCore(@Nullable String root, Iterable<String> path); static Parser parser(String separator); static Parser namedRootParser(String separator, NamedRootFormat format, String rootId); @Override boolean isAbsolute(); @Override ImmutableListPathCore getRoot(); @Override ImmutableListPathCore getFileName(); @Override ImmutableListPathCore getParent(); @Override int getNameCount(); @Override ImmutableListPathCore getName(int index); @Override ImmutableListPathCore subpath(int beginIndex, int endIndex); @Override boolean startsWith(ImmutableListPathCore other); @Override boolean endsWith(ImmutableListPathCore other); @Override ImmutableListPathCore normalize(); @Override ImmutableListPathCore resolve(ImmutableListPathCore other); @Override ImmutableListPathCore resolveSibling(ImmutableListPathCore other); @Override ImmutableListPathCore relativize(ImmutableListPathCore other); @Override String toPathString(String separator); @Override String toString(); @Override int compareTo(ImmutableListPathCore other); @Override boolean equals(Object obj); @Override int hashCode(); @Nullable String getRootString(); ImmutableList<String> getPathSegments();  }
@Test public void rootToPathString() { assertEquals("path string is wrong", "/", root.toPathString("/")); assertEquals("path string is wrong", "C:/", rootNamed.toPathString("/")); }
@Test public void absoluteToPathString() { assertEquals("path string is wrong", "/path/to/file", absolute.toPathString("/")); assertEquals("path string is wrong", "C:/path/to/file", absoluteNamed.toPathString("/")); }
@Test public void relativeToPathString() { assertEquals("path string is wrong", "path/to/file", relative.toPathString("/")); }