@Override public boolean matchCommunities(Environment environment, Set<Long> communitySetCandidate) { return resolve(environment).matchCommunities(environment, communitySetCandidate); }
@Override public boolean matchCommunities(Environment environment, Set<Long> communitySetCandidate) { if (reducible()) { return communitySetCandidate.stream() .anyMatch(community -> matchCommunity(environment, community)); } Optional<CommunityListLine> matchingLine = _lines.stream() .filter( line -> line.getMatchCondition().matchCommunities(environment, communitySetCandidate)) .findFirst(); // "invert != condition" is a concise way of inverting a boolean return matchingLine.isPresent() && _invertMatch != (matchingLine.get().getAction() == LineAction.PERMIT); }
@Override protected boolean matchesSafely(CommunitySetExpr item, Description mismatchDescription) { boolean match = item.matchCommunities(_environment, _communitySetCandidate); if (!match) { mismatchDescription.appendText( String.format( "CommunitySetExpr: '%s' did not match the community-set: '%s'", item, CommunitySetExprMatchers.toString(_communitySetCandidate))); return false; } return true; } }