@Test public void testVisitCommunitySetAcl() { CommunitySetAcl csacl = new CommunitySetAcl( ImmutableList.of( new CommunitySetAclLine( LineAction.DENY, new HasCommunity(new CommunityIs(StandardCommunity.parse("20:30")))), new CommunitySetAclLine( LineAction.PERMIT, new HasCommunity( new CommunityMatchRegex(ColonSeparatedRendering.instance(), "^20:"))))); BDD result = _communitySetMatchExprToBDD.visitCommunitySetAcl(csacl, _arg); CommunityVar cvar1 = CommunityVar.from(StandardCommunity.parse("20:30")); CommunityVar cvar2 = CommunityVar.from("^20:"); assertEquals(cvarToBDD(cvar1).not().and(cvarToBDD(cvar2)), result); }
@Override public BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg) { List<CommunitySetAclLine> lines = new ArrayList<>(communitySetAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunitySetAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunitySetMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg) { List<CommunitySetAclLine> lines = new ArrayList<>(communitySetAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunitySetAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunitySetMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; } }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg) { List<CommunitySetAclLine> lines = new ArrayList<>(communitySetAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunitySetAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunitySetMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  }
CommunitySetMatchExprToBDD implements CommunitySetMatchExprVisitor<BDD, CommunitySetMatchExprToBDD.Arg> { @Override public BDD visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg) { List<CommunitySetAclLine> lines = new ArrayList<>(communitySetAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunitySetAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunitySetMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  @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 visitCommunitySetAcl(CommunitySetAcl communitySetAcl, Arg arg) { List<CommunitySetAclLine> lines = new ArrayList<>(communitySetAcl.getLines()); Collections.reverse(lines); BDD acc = BDDRoute.factory.zero(); for (CommunitySetAclLine line : lines) { boolean action = (line.getAction() == LineAction.PERMIT); BDD lineBDD = line.getCommunitySetMatchExpr().accept(this, arg); acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc); } return acc; }  @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);  }