MagicCommitPaths { public static List<String> splitPathToElements(Path path) { checkArgument(path.isAbsolute(), "path is relative"); String uriPath = path.toUri().getPath(); checkArgument(!uriPath.isEmpty(), "empty path"); if ("/".equals(uriPath)) { return new ArrayList<>(0); } List<String> elements = new ArrayList<>(); int len = uriPath.length(); int firstElementChar = 1; int endOfElement = uriPath.indexOf('/', firstElementChar); while (endOfElement > 0) { elements.add(uriPath.substring(firstElementChar, endOfElement)); firstElementChar = endOfElement + 1; endOfElement = firstElementChar == len ? -1 : uriPath.indexOf('/', firstElementChar); } if (firstElementChar != len) { elements.add(uriPath.substring(firstElementChar)); } return elements; } private  MagicCommitPaths(); static List<String> splitPathToElements(Path path); static boolean isMagicPath(List<String> elements); static boolean containsBasePath(List<String> elements); static int magicElementIndex(List<String> elements); static List<String> magicPathParents(List<String> elements); static List<String> magicPathChildren(List<String> elements); static List<String> basePathChildren(List<String> elements); static String elementsToKey(List<String> elements); static String filename(List<String> elements); static String lastElement(List<String> strings); static Path magicSubdir(Path destDir); static List<String> finalDestination(List<String> elements);  }
@Test public void testSplitPathEmpty() throws Throwable { intercept(IllegalArgumentException.class, () -> splitPathToElements(new Path(""))); }