@Test public void testEvaluate() { Configuration c = new Configuration("h", ConfigurationFormat.CISCO_IOS); c.setCommunitySetMatchExprs( ImmutableMap.of("a", new HasCommunity(new CommunityIs(StandardCommunity.of(1L))))); Environment env = Environment.builder(c).build(); MatchCommunities matching = new MatchCommunities( new LiteralCommunitySet(CommunitySet.of(StandardCommunity.of(1L))), new CommunitySetMatchExprReference("a")); assertTrue(matching.evaluate(env).getBooleanValue()); MatchCommunities notMatching = new MatchCommunities( new LiteralCommunitySet(CommunitySet.empty()), new CommunitySetMatchExprReference("a")); assertFalse(notMatching.evaluate(env).getBooleanValue()); }
@Override public @Nonnull Result evaluate(Environment environment) { CommunityContext ctx = CommunityContext.fromEnvironment(environment); CommunitySet communitySet = _communitySetExpr.accept(CommunitySetExprEvaluator.instance(), ctx); boolean ret = _communitySetMatchExpr.accept(ctx.getCommunitySetMatchExprEvaluator(), communitySet); return Result.builder().setBooleanValue(ret).build(); }
MatchCommunities extends BooleanExpr { @Override public @Nonnull Result evaluate(Environment environment) { CommunityContext ctx = CommunityContext.fromEnvironment(environment); CommunitySet communitySet = _communitySetExpr.accept(CommunitySetExprEvaluator.instance(), ctx); boolean ret = _communitySetMatchExpr.accept(ctx.getCommunitySetMatchExprEvaluator(), communitySet); return Result.builder().setBooleanValue(ret).build(); } }
MatchCommunities extends BooleanExpr { @Override public @Nonnull Result evaluate(Environment environment) { CommunityContext ctx = CommunityContext.fromEnvironment(environment); CommunitySet communitySet = _communitySetExpr.accept(CommunitySetExprEvaluator.instance(), ctx); boolean ret = _communitySetMatchExpr.accept(ctx.getCommunitySetMatchExprEvaluator(), communitySet); return Result.builder().setBooleanValue(ret).build(); } MatchCommunities(
      CommunitySetExpr communitySetExpr, CommunitySetMatchExpr communitySetMatchExpr); }
MatchCommunities extends BooleanExpr { @Override public @Nonnull Result evaluate(Environment environment) { CommunityContext ctx = CommunityContext.fromEnvironment(environment); CommunitySet communitySet = _communitySetExpr.accept(CommunitySetExprEvaluator.instance(), ctx); boolean ret = _communitySetMatchExpr.accept(ctx.getCommunitySetMatchExprEvaluator(), communitySet); return Result.builder().setBooleanValue(ret).build(); } MatchCommunities(
      CommunitySetExpr communitySetExpr, CommunitySetMatchExpr communitySetMatchExpr); @Override T accept(BooleanExprVisitor<T, U> visitor, U arg); @Override @Nonnull Result evaluate(Environment environment); @JsonProperty(PROP_COMMUNITY_SET_EXPR) @Nonnull CommunitySetExpr getCommunitySetExpr(); @JsonProperty(PROP_COMMUNITY_SET_MATCH_EXPR) @Nonnull CommunitySetMatchExpr getCommunitySetMatchExpr(); @Override boolean equals(Object obj); @Override int hashCode(); }
MatchCommunities extends BooleanExpr { @Override public @Nonnull Result evaluate(Environment environment) { CommunityContext ctx = CommunityContext.fromEnvironment(environment); CommunitySet communitySet = _communitySetExpr.accept(CommunitySetExprEvaluator.instance(), ctx); boolean ret = _communitySetMatchExpr.accept(ctx.getCommunitySetMatchExprEvaluator(), communitySet); return Result.builder().setBooleanValue(ret).build(); } MatchCommunities(
      CommunitySetExpr communitySetExpr, CommunitySetMatchExpr communitySetMatchExpr); @Override T accept(BooleanExprVisitor<T, U> visitor, U arg); @Override @Nonnull Result evaluate(Environment environment); @JsonProperty(PROP_COMMUNITY_SET_EXPR) @Nonnull CommunitySetExpr getCommunitySetExpr(); @JsonProperty(PROP_COMMUNITY_SET_MATCH_EXPR) @Nonnull CommunitySetMatchExpr getCommunitySetMatchExpr(); @Override boolean equals(Object obj); @Override int hashCode();  }