SupportedPaths { boolean includes(@NotNull String path) { if (supportedPaths.length == 0) { return false; } if (includesRootPath) { return true; } for (String p : supportedAltPaths) { if (path.startsWith(p)) { return true; } } for (String p : supportedPaths) { if (path.equals(p)) { return true; } } return false; } SupportedPaths(@NotNull Set<String> supportedPaths);   }
@Test public void testIncludes() { SupportedPaths supportedPaths = new SupportedPaths(ImmutableSet.of("/content")); Map<String, Boolean> pathMap = new HashMap<>(); pathMap.put("/content", true); pathMap.put("/content/a", true); pathMap.put("/content/a/rep:cugPolicy", true); pathMap.put("/content/a/b", true); pathMap.put("/content/a/b/c/jcr:primaryType", true); pathMap.put("/content/aa", true); pathMap.put("/content/aa/bb/cc", true); pathMap.put("/jcr:system", false); pathMap.put("/", false); pathMap.put("/testRoot", false); pathMap.put("/some/other/path", false); for (String path : pathMap.keySet()) { boolean expected = pathMap.get(path); assertEquals(path, expected, supportedPaths.includes(path)); assertEquals(path, expected, supportedPaths.includes(path + '/')); } }