@Test public void testVisitCommunitySetDifference() { CommunitySet cs = CommunitySet.of(StandardCommunity.of(1L), StandardCommunity.of(2L)); assertThat( eval( new CommunitySetDifference( new LiteralCommunitySet(cs), new CommunityIs(StandardCommunity.of(1L)))), equalTo(CommunitySet.of(StandardCommunity.of(2L)))); }
@Override public @Nonnull CommunitySet visitCommunitySetDifference( CommunitySetDifference communitySetDifference, CommunityContext arg) { CommunitySet initial = communitySetDifference.getInitial().accept(this, arg); CommunityMatchExpr removalCriterion = communitySetDifference.getRemovalCriterion(); return CommunitySet.of( initial.getCommunities().stream() .filter(c -> !removalCriterion.accept(arg.getCommunityMatchExprEvaluator(), c)) .collect(ImmutableSet.toImmutableSet())); }
CommunitySetExprEvaluator implements CommunitySetExprVisitor<CommunitySet, CommunityContext> { @Override public @Nonnull CommunitySet visitCommunitySetDifference( CommunitySetDifference communitySetDifference, CommunityContext arg) { CommunitySet initial = communitySetDifference.getInitial().accept(this, arg); CommunityMatchExpr removalCriterion = communitySetDifference.getRemovalCriterion(); return CommunitySet.of( initial.getCommunities().stream() .filter(c -> !removalCriterion.accept(arg.getCommunityMatchExprEvaluator(), c)) .collect(ImmutableSet.toImmutableSet())); } }
CommunitySetExprEvaluator implements CommunitySetExprVisitor<CommunitySet, CommunityContext> { @Override public @Nonnull CommunitySet visitCommunitySetDifference( CommunitySetDifference communitySetDifference, CommunityContext arg) { CommunitySet initial = communitySetDifference.getInitial().accept(this, arg); CommunityMatchExpr removalCriterion = communitySetDifference.getRemovalCriterion(); return CommunitySet.of( initial.getCommunities().stream() .filter(c -> !removalCriterion.accept(arg.getCommunityMatchExprEvaluator(), c)) .collect(ImmutableSet.toImmutableSet())); } private  CommunitySetExprEvaluator(); }
CommunitySetExprEvaluator implements CommunitySetExprVisitor<CommunitySet, CommunityContext> { @Override public @Nonnull CommunitySet visitCommunitySetDifference( CommunitySetDifference communitySetDifference, CommunityContext arg) { CommunitySet initial = communitySetDifference.getInitial().accept(this, arg); CommunityMatchExpr removalCriterion = communitySetDifference.getRemovalCriterion(); return CommunitySet.of( initial.getCommunities().stream() .filter(c -> !removalCriterion.accept(arg.getCommunityMatchExprEvaluator(), c)) .collect(ImmutableSet.toImmutableSet())); } private  CommunitySetExprEvaluator(); static @Nonnull CommunitySetExprEvaluator instance(); @Override @Nonnull CommunitySet visitInputCommunities(
      InputCommunities inputCommunities, CommunityContext arg); @Override CommunitySet visitCommunityExprsSet(
      CommunityExprsSet communityExprsSet, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetDifference(
      CommunitySetDifference communitySetDifference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetExprReference(
      CommunitySetExprReference communitySetExprReference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetReference(
      CommunitySetReference communitySetReference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetUnion(
      CommunitySetUnion communitySetUnion, CommunityContext arg); @Override @Nonnull CommunitySet visitLiteralCommunitySet(
      LiteralCommunitySet literalCommunitySet, CommunityContext arg); }
CommunitySetExprEvaluator implements CommunitySetExprVisitor<CommunitySet, CommunityContext> { @Override public @Nonnull CommunitySet visitCommunitySetDifference( CommunitySetDifference communitySetDifference, CommunityContext arg) { CommunitySet initial = communitySetDifference.getInitial().accept(this, arg); CommunityMatchExpr removalCriterion = communitySetDifference.getRemovalCriterion(); return CommunitySet.of( initial.getCommunities().stream() .filter(c -> !removalCriterion.accept(arg.getCommunityMatchExprEvaluator(), c)) .collect(ImmutableSet.toImmutableSet())); } private  CommunitySetExprEvaluator(); static @Nonnull CommunitySetExprEvaluator instance(); @Override @Nonnull CommunitySet visitInputCommunities(
      InputCommunities inputCommunities, CommunityContext arg); @Override CommunitySet visitCommunityExprsSet(
      CommunityExprsSet communityExprsSet, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetDifference(
      CommunitySetDifference communitySetDifference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetExprReference(
      CommunitySetExprReference communitySetExprReference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetReference(
      CommunitySetReference communitySetReference, CommunityContext arg); @Override @Nonnull CommunitySet visitCommunitySetUnion(
      CommunitySetUnion communitySetUnion, CommunityContext arg); @Override @Nonnull CommunitySet visitLiteralCommunitySet(
      LiteralCommunitySet literalCommunitySet, CommunityContext arg);  }