@Override public boolean matchCommunity(Environment environment, long community) { return _pattern.get().matcher(CommonUtil.longToCommunity(community)).find(); }
public static @Nonnull CommunityVar toCommunityVar(long community) { return new CommunityVar(Type.EXACT, CommonUtil.longToCommunity(community), community); }
@Override public RegexCommunitySet visitLiteralCommunity(LiteralCommunity literalCommunity) { return new RegexCommunitySet( String.format("^%s$", CommonUtil.longToCommunity(literalCommunity.getCommunity()))); }
@Override public void describeTo(Description description) { description.appendText( String.format( "A CommunitySetExpr matching the individual comunity: %s", longToCommunity(_community))); }
@Test public void testLongToCommunity() { assertThat(longToCommunity(0L), equalTo("0:0")); assertThat(longToCommunity(4294967295L), equalTo("65535:65535")); } }
@Override protected boolean matchesSafely(CommunitySetExpr item, Description mismatchDescription) { boolean match = item.matchCommunity(_environment, _community); if (!match) { mismatchDescription.appendText( String.format( "CommunitySetExpr: '%s' did not match the community: '%s'", item, longToCommunity(_community))); return false; } return true; } }
private static CommunityVar toRegexCommunityVar(CommunityVar cvar) { switch (cvar.getType()) { case REGEX: return cvar; case EXACT: return new CommunityVar( Type.REGEX, String.format("^%s$", CommonUtil.longToCommunity(cvar.asLong())), null); default: throw new BatfishException("Unexpected CommunityVar type: " + cvar.getType()); } } }
String communityStr = CommonUtil.longToCommunity(communityVal); _currentCommunityList.getLines().add(new CommunityListLine(communityStr)); } else if (ctx.extended_community() != null) { long communityVal = toCommunityLong(ctx.extended_community()); String communityStr = CommonUtil.longToCommunity(communityVal); _currentCommunityList.getLines().add(new CommunityListLine(communityStr)); } else if (ctx.invalid_community_regex() != null) {