public ResourceChildrenMatcher()

in src/main/java/org/apache/sling/hamcrest/matchers/ResourceChildrenMatcher.java [38:61]


    public ResourceChildrenMatcher(List<String> childNames, boolean exactMatch, boolean validateOrder) {
        if ( childNames == null || childNames.isEmpty() ) {
            throw new IllegalArgumentException("childNames is null or empty");
        }

        if (!exactMatch && validateOrder) {
            throw new IllegalArgumentException("Can only validate the order for exact matches");
        }

        List<Matcher<? super Resource>> resourceMatchers = new ArrayList<Matcher<? super Resource>>();
        for (String childName : childNames) {
            resourceMatchers.add(new ResourceNameMatcher(childName));
        }

        if (exactMatch) {
            if (validateOrder) {
                this.iterarableMatcher = org.hamcrest.collection.IsIterableContainingInOrder.contains(resourceMatchers);
            } else {
                this.iterarableMatcher = org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder(resourceMatchers);
            }
        } else {
            this.iterarableMatcher = org.hamcrest.core.IsIterableContaining.hasItems(resourceMatchers.toArray(new ResourceNameMatcher[0]));
        }
    }