int matchedSize = list.size();
if (list == null || list.isEmpty() || matchedSize < minValue) {
return true;
}
RuleElementMatch lastMatch = null;
if (after) {
lastMatch = list.get(list.size() - 1);
} else {
lastMatch = list.get(0);
}
RuleElement nextElement = ruleElement.getContainer().getNextElement(after, ruleElement);
if (nextElement == null) {
return false;
}
ComposedRuleElementMatch extendedContainerMatch = containerMatch.copy();
RuleMatch extendedMatch = ruleMatch.copy(extendedContainerMatch);
nextElement.continueMatch(after, annotation, extendedMatch, null, extendedContainerMatch, null,
nextElement, stream, crowd);
List<RuleElementMatch> nextList = extendedContainerMatch.getInnerMatches().get(nextElement);
boolean nextMatched = (nextList != null && !nextList.isEmpty());
return (matchedSize < maxValue && matchedSize >= minValue && !nextMatched)
|| (!lastMatch.matched() && matchedSize >= minValue && matchedSize <= maxValue && !nextMatched);
}