Path { public String getName() { if (elements.isEmpty()) return ""; return elements.get(elements.size() - 1); } private  Path(String delimiter); private  Path(Path path); private  Path(List<String> elements, String delimiter); boolean isChildOf(Path parent); Path append(String path); Path append(Path path); String getName(); String getRelative(); Path getParentPath(); Path getChildPath(); String last(); Path withLast(String element); String getAbsolute(); boolean isRoot(); Iterator<String> iterator(); List<String> elements(); @Override String toString(); static Path fromString(String path); static Path fromString(String path, String delimiter); static Path createRoot(); static Path createRoot(String delimiter); File toFile(); @Override int hashCode(); @Override boolean equals(Object other);  }
@Test public void testGetName() { assertThat(getAbsolutePath().getName(), is("baz")); assertThat(getRelativePath().getName(), is("baz")); assertThat(getWithSlashes().getName(), is("baz")); assertThat(getAppended().getName(), is("baz")); assertThat(getOne().getName(), is("foo")); }