Path { public String getName() { if (isEmptyPath()) return ""; return getSegments().get(getSegments().size() - 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 testGetName() { assertThat(new Path("foo").getName(), is("foo")); assertThat(new Path("foo/bar").getName(), is("bar")); }