package org.batfish.datamodel.routing_policy.expr;

import org.batfish.datamodel.AbstractRouteBuilder;
import org.batfish.datamodel.BgpRoute;
import org.batfish.datamodel.routing_policy.Environment;
import org.batfish.datamodel.routing_policy.Result;

import com.fasterxml.jackson.annotation.JsonCreator;

public class MatchCommunitySet extends AbstractBooleanExpr {

   /**
    *
    */
   private static final long serialVersionUID = 1L;

   private CommunitySetExpr _expr;

   @JsonCreator
   public MatchCommunitySet() {
   }

   public MatchCommunitySet(CommunitySetExpr expr) {
      _expr = expr;
   }

   @Override
   public Result evaluate(Environment environment,
         AbstractRouteBuilder<?> outputRoute) {
      Result result = new Result();
      BgpRoute bgpRoute = (BgpRoute) environment.getOriginalRoute();
      boolean match = _expr.matchSingleCommunity(environment,
            bgpRoute.getCommunities());
      result.setBooleanValue(match);
      return result;
   }

   public CommunitySetExpr getExpr() {
      return _expr;
   }

   public void setExpr(CommunitySetExpr expr) {
      _expr = expr;
   }

}

@@ -747,24 +747,120 @@
 w Result();%0A
+      boolean match = false;%0A      if (environment.getOriginalRoute() instanceof BgpRoute) %7B%0A   
       BgpRou
@@ -914,39 +914,34 @@
 lRoute();%0A      
-boolean
+  
  match = _expr.m
@@ -985,16 +985,19 @@
         
+   
 bgpRoute
@@ -1016,16 +1016,24 @@
 ies());%0A
+      %7D%0A
       re

fix routing policy community matching for non-bgp routes