Path { public Path getParent() { if (isEmptyPath()) return null; return subpath(0, getDepth() - 1); } Path(String path); Path append(Path append); int getDepth(); String getName(); Path getParent(); List<String> getSegments(); boolean isEmptyPath(); Path subpath(int from, int to); @Override String toString();  }
@Test public void testGetParent() { assertThat(new Path("").getParent(), nullValue()); assertThat(new Path("bar").getParent().isEmptyPath(), is(true)); assertThat(new Path("foo/bar").getParent().toString(), is("foo")); }