@Test public void testPathsWithValidCharacters() { assertTrue(PathUtilities.isValid("level1")); assertTrue(PathUtilities.isValid("level-1")); assertTrue(PathUtilities.isValid("level-1/level-2/level3")); assertTrue(PathUtilities.isValid("1/2/a")); }
static boolean isValid(String path) { Objects.requireNonNull(path, "Path can't be null"); if ("/".equals(path)) { return true; } if (path.startsWith("/")) { path = path.substring(1); } for (String part : split(path)) { if (!isPathNameValid(part)) { return false; } } return true; }
PathUtilities { static boolean isValid(String path) { Objects.requireNonNull(path, "Path can't be null"); if ("/".equals(path)) { return true; } if (path.startsWith("/")) { path = path.substring(1); } for (String part : split(path)) { if (!isPathNameValid(part)) { return false; } } return true; } }
PathUtilities { static boolean isValid(String path) { Objects.requireNonNull(path, "Path can't be null"); if ("/".equals(path)) { return true; } if (path.startsWith("/")) { path = path.substring(1); } for (String part : split(path)) { if (!isPathNameValid(part)) { return false; } } return true; }  }
PathUtilities { static boolean isValid(String path) { Objects.requireNonNull(path, "Path can't be null"); if ("/".equals(path)) { return true; } if (path.startsWith("/")) { path = path.substring(1); } for (String part : split(path)) { if (!isPathNameValid(part)) { return false; } } return true; }   }
PathUtilities { static boolean isValid(String path) { Objects.requireNonNull(path, "Path can't be null"); if ("/".equals(path)) { return true; } if (path.startsWith("/")) { path = path.substring(1); } for (String part : split(path)) { if (!isPathNameValid(part)) { return false; } } return true; }    }