private void ensureExpandable()

in bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java [98:120]


    private void ensureExpandable(List<Group> groupList, List<Group> defaultGroupList, int defaultGroupIndex) {
        for (int i = 0, sz = defaultGroupList.size(); i < sz; i++) {
            final Group group = defaultGroupList.get(i);
            if (group.isDefault()) {
                continue; // the default group is the one we want to replace
            }
            // sequence contains group of default group sequence
            final int index = groupList.indexOf(group);
            if (index < 0) {
                // group is not in the sequence
                continue;
            }
            if ((i == 0 && index == defaultGroupIndex - 1)
                || (i == defaultGroupList.size() - 1 && index == defaultGroupIndex + 1)) {
                // if we are at the beginning or end of he defaultGroupSequence
                // and the matches are either directly before or after we can
                // continue, since we basically have two groups
                continue;
            }
            Exceptions.raise(GroupDefinitionException::new, "Unable to expand default group list %s into sequence %s",
                defaultGroupList, groupList);
        }
    }