BundlorUtils { public static Set<String> getChildNodeNames(Collection<String> keys, Matcher matcher){ Set<String> childNodeNames = Sets.newHashSet(); int expectedDepth = matcher.depth() + 1; for (String key : keys){ List<String> elements = ImmutableList.copyOf(PathUtils.elements(key)); int depth = elements.size() - 1; if (depth == expectedDepth && key.startsWith(matcher.getMatchedPath()) && elements.get(elements.size() - 1).equals(META_PROP_BUNDLING_PATH)){ childNodeNames.add(elements.get(elements.size() - 2)); } } return childNodeNames; }  static Map<String, PropertyState> getMatchingProperties(Map<String, PropertyState> props, Matcher matcher); static Set<String> getChildNodeNames(Collection<String> keys, Matcher matcher); static final Predicate<PropertyState> NOT_BUNDLOR_PROPS; }
@Test public void childNodeNames() throws Exception{ List<String> testData = asList("x", concat("jcr:content", META_PROP_BUNDLING_PATH), "jcr:content/jcr:data", concat("jcr:content/metadata", META_PROP_BUNDLING_PATH), "jcr:content/metadata/format", concat("jcr:content/comments", META_PROP_BUNDLING_PATH), concat("jcr:content/renditions/original", META_PROP_BUNDLING_PATH) ); Matcher m = new Include("jcr:content/*").createMatcher(); Set<String> names = BundlorUtils.getChildNodeNames(testData, m); assertThat(names, hasItem("jcr:content")); names = BundlorUtils.getChildNodeNames(testData, m.next("jcr:content")); assertThat(names, hasItems("metadata", "comments")); names = BundlorUtils.getChildNodeNames(testData, m.next("jcr:content").next("metadata")); assertTrue(names.isEmpty()); }