@Test public void testVisitHasCommunity() { HasCommunity hc = new HasCommunity( new CommunityMatchAll( ImmutableList.of( new CommunityMatchRegex(ColonSeparatedRendering.instance(), "^20:"), new CommunityMatchRegex(ColonSeparatedRendering.instance(), ":30$")))); BDD result = _communitySetMatchExprToBDD.visitHasCommunity(hc, _arg); CommunityVar cvar = CommunityVar.from(StandardCommunity.parse("20:30")); assertEquals(cvarToBDD(cvar), result); }
@Override public BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg) { BDD matchExprBDD = hasCommunity.getExpr().accept(new CommunityMatchExprToBDD(), arg); BDD[] aps = arg.getBDDRoute().getCommunityAtomicPredicates(); IntStream disjuncts = IntStream.range(0, aps.length).filter(i -> !exactlyOneAP(aps, i).diffSat(matchExprBDD)); return BDDRoute.factory.orAll(disjuncts.mapToObj(i -> aps[i]).collect(Collectors.toList())); }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg) { BDD matchExprBDD = hasCommunity.getExpr().accept(new CommunityMatchExprToBDD(), arg); BDD[] aps = arg.getBDDRoute().getCommunityAtomicPredicates(); IntStream disjuncts = IntStream.range(0, aps.length).filter(i -> !exactlyOneAP(aps, i).diffSat(matchExprBDD)); return BDDRoute.factory.orAll(disjuncts.mapToObj(i -> aps[i]).collect(Collectors.toList())); } }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg) { BDD matchExprBDD = hasCommunity.getExpr().accept(new CommunityMatchExprToBDD(), arg); BDD[] aps = arg.getBDDRoute().getCommunityAtomicPredicates(); IntStream disjuncts = IntStream.range(0, aps.length).filter(i -> !exactlyOneAP(aps, i).diffSat(matchExprBDD)); return BDDRoute.factory.orAll(disjuncts.mapToObj(i -> aps[i]).collect(Collectors.toList())); }  }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg) { BDD matchExprBDD = hasCommunity.getExpr().accept(new CommunityMatchExprToBDD(), arg); BDD[] aps = arg.getBDDRoute().getCommunityAtomicPredicates(); IntStream disjuncts = IntStream.range(0, aps.length).filter(i -> !exactlyOneAP(aps, i).diffSat(matchExprBDD)); return BDDRoute.factory.orAll(disjuncts.mapToObj(i -> aps[i]).collect(Collectors.toList())); }  @Override BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg); @Override BDD visitCommunitySetMatchAll(CommunitySetMatchAll communitySetMatchAll, Arg arg); @Override BDD visitCommunitySetMatchAny(CommunitySetMatchAny communitySetMatchAny, Arg arg); @Override BDD visitCommunitySetMatchExprReference(
      CommunitySetMatchExprReference communitySetMatchExprReference, Arg arg); @Override BDD visitCommunitySetMatchRegex(CommunitySetMatchRegex communitySetMatchRegex, Arg arg); @Override BDD visitCommunitySetNot(CommunitySetNot communitySetNot, Arg arg); @Override BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg); }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg) { BDD matchExprBDD = hasCommunity.getExpr().accept(new CommunityMatchExprToBDD(), arg); BDD[] aps = arg.getBDDRoute().getCommunityAtomicPredicates(); IntStream disjuncts = IntStream.range(0, aps.length).filter(i -> !exactlyOneAP(aps, i).diffSat(matchExprBDD)); return BDDRoute.factory.orAll(disjuncts.mapToObj(i -> aps[i]).collect(Collectors.toList())); }  @Override BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg); @Override BDD visitCommunitySetMatchAll(CommunitySetMatchAll communitySetMatchAll, Arg arg); @Override BDD visitCommunitySetMatchAny(CommunitySetMatchAny communitySetMatchAny, Arg arg); @Override BDD visitCommunitySetMatchExprReference(
      CommunitySetMatchExprReference communitySetMatchExprReference, Arg arg); @Override BDD visitCommunitySetMatchRegex(CommunitySetMatchRegex communitySetMatchRegex, Arg arg); @Override BDD visitCommunitySetNot(CommunitySetNot communitySetNot, Arg arg); @Override BDD visitHasCommunity(HasCommunity hasCommunity, Arg arg);  }