class CommunityMatchExprToBDD implements CommunityMatchExprVisitor<BDD, Arg> {

  @Override
  public BDD visitCommunityAcl(CommunityAcl communityAcl, Arg arg) {
    List<CommunityAclLine> lines = new ArrayList<>(communityAcl.getLines());
    Collections.reverse(lines);
    BDD acc = BDDRoute.factory.zero();
    for (CommunityAclLine line : lines) {
      boolean action = (line.getAction() == LineAction.PERMIT);
      BDD lineBDD = line.getCommunityMatchExpr().accept(this, arg);
      acc = lineBDD.ite(arg.getTransferBDD().mkBDD(action), acc);
    }
    return acc;
  }

}