@Test public void testMatchCommunities() { Set<Community> matchingCommunitySetCandidate1 = ImmutableSet.of(StandardCommunity.parse("1:1"), StandardCommunity.parse("2:2")); Set<Community> matchingCommunitySetCandidate2 = ImmutableSet.of(StandardCommunity.parse("1:1")); Set<Community> nonMatchingCommunitySetCandidate = ImmutableSet.of(StandardCommunity.parse("2:2")); CommunityHalvesExpr expr = new CommunityHalvesExpr(new LiteralCommunityHalf(1), new LiteralCommunityHalf(1)); assertThat(expr, matchCommunities(null, matchingCommunitySetCandidate1)); assertThat(expr, matchCommunities(null, matchingCommunitySetCandidate2)); assertThat(expr, not(matchCommunities(null, nonMatchingCommunitySetCandidate))); }
@Override public boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate) { return communitySetCandidate.stream() .anyMatch(communityCandidate -> matchCommunity(environment, communityCandidate)); }
CommunityHalvesExpr extends CommunitySetExpr { @Override public boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate) { return communitySetCandidate.stream() .anyMatch(communityCandidate -> matchCommunity(environment, communityCandidate)); } }
CommunityHalvesExpr extends CommunitySetExpr { @Override public boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate) { return communitySetCandidate.stream() .anyMatch(communityCandidate -> matchCommunity(environment, communityCandidate)); } CommunityHalvesExpr(@Nonnull CommunityHalfExpr left, @Nonnull CommunityHalfExpr right); }
CommunityHalvesExpr extends CommunitySetExpr { @Override public boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate) { return communitySetCandidate.stream() .anyMatch(communityCandidate -> matchCommunity(environment, communityCandidate)); } CommunityHalvesExpr(@Nonnull CommunityHalfExpr left, @Nonnull CommunityHalfExpr right); @Override T accept(CommunitySetExprVisitor<T> visitor); @Override void accept(VoidCommunitySetExprVisitor visitor); @Nonnull @Override Set<Community> asLiteralCommunities(@Nonnull Environment environment); @Override boolean dynamicMatchCommunity(); @Override boolean equals(Object obj); @JsonProperty(PROP_LEFT) @Nonnull CommunityHalfExpr getLeft(); @JsonProperty(PROP_RIGHT) @Nonnull CommunityHalfExpr getRight(); @Override int hashCode(); @Override boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate); @Override boolean matchCommunity(Environment environment, Community community); @Override boolean reducible(); @Override String toString(); }
CommunityHalvesExpr extends CommunitySetExpr { @Override public boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate) { return communitySetCandidate.stream() .anyMatch(communityCandidate -> matchCommunity(environment, communityCandidate)); } CommunityHalvesExpr(@Nonnull CommunityHalfExpr left, @Nonnull CommunityHalfExpr right); @Override T accept(CommunitySetExprVisitor<T> visitor); @Override void accept(VoidCommunitySetExprVisitor visitor); @Nonnull @Override Set<Community> asLiteralCommunities(@Nonnull Environment environment); @Override boolean dynamicMatchCommunity(); @Override boolean equals(Object obj); @JsonProperty(PROP_LEFT) @Nonnull CommunityHalfExpr getLeft(); @JsonProperty(PROP_RIGHT) @Nonnull CommunityHalfExpr getRight(); @Override int hashCode(); @Override boolean matchCommunities(Environment environment, Set<Community> communitySetCandidate); @Override boolean matchCommunity(Environment environment, Community community); @Override boolean reducible(); @Override String toString();  }