@Test public void testToAutomaton() { CommunityVar cv0 = CommunityVar.from(StandardCommunity.of(20, 30)); CommunityVar cv1 = CommunityVar.from(ExtendedCommunity.of(10, 20, 30)); CommunityVar cv2 = CommunityVar.from(LargeCommunity.of(10, 20, 30)); CommunityVar cv3 = CommunityVar.from("^.*$"); CommunityVar cv4 = CommunityVar.from("^40:"); CommunityVar cv5 = CommunityVar.from("(,|{|}|^|$| )" + "40:50" + "(,|{|}|^|$| )"); CommunityVar cv6 = CommunityVar.from("^0:.0$"); assertThat(cv0.toAutomaton(), equalTo(new RegExp("^20:30$").toAutomaton())); assertThat(cv1.toAutomaton(), equalTo(new RegExp("^20:30$").toAutomaton())); assertThat(cv2.toAutomaton(), equalTo(new RegExp("^large:10:20:30$").toAutomaton())); assertThat(cv3.toAutomaton(), equalTo(CommunityVar.COMMUNITY_FSM)); assertThat(cv4.toAutomaton(), equalTo(new RegExp("^40:(0|[1-9][0-9]*)$").toAutomaton())); assertThat(cv5.toAutomaton(), equalTo(new RegExp("^40:50$").toAutomaton())); assertThat(cv6.toAutomaton(), equalTo(new RegExp("^0:[1-9]0$").toAutomaton())); }
@Override public Automaton toAutomaton() { String regex = _regex; if (_type == EXACT) { regex = "^" + "(" + regex + ")" + "$"; } else { regex = ".*" + "(" + regex + ")" + ".*"; } return new RegExp(regex).toAutomaton().intersection(COMMUNITY_FSM); }
CommunityVar extends SymbolicRegex implements Comparable<CommunityVar> { @Override public Automaton toAutomaton() { String regex = _regex; if (_type == EXACT) { regex = "^" + "(" + regex + ")" + "$"; } else { regex = ".*" + "(" + regex + ")" + ".*"; } return new RegExp(regex).toAutomaton().intersection(COMMUNITY_FSM); } }
CommunityVar extends SymbolicRegex implements Comparable<CommunityVar> { @Override public Automaton toAutomaton() { String regex = _regex; if (_type == EXACT) { regex = "^" + "(" + regex + ")" + "$"; } else { regex = ".*" + "(" + regex + ")" + ".*"; } return new RegExp(regex).toAutomaton().intersection(COMMUNITY_FSM); } private  CommunityVar(Type type, String regex, @Nullable Community literalValue); }
CommunityVar extends SymbolicRegex implements Comparable<CommunityVar> { @Override public Automaton toAutomaton() { String regex = _regex; if (_type == EXACT) { regex = "^" + "(" + regex + ")" + "$"; } else { regex = ".*" + "(" + regex + ")" + ".*"; } return new RegExp(regex).toAutomaton().intersection(COMMUNITY_FSM); } private  CommunityVar(Type type, String regex, @Nullable Community literalValue); static CommunityVar from(String regex); static CommunityVar from(Community literalCommunity); static CommunityVar other(String regex); @Nonnull Type getType(); @Nullable Community getLiteralValue(); @Override Automaton toAutomaton(); @Override String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override int compareTo(CommunityVar that); }
CommunityVar extends SymbolicRegex implements Comparable<CommunityVar> { @Override public Automaton toAutomaton() { String regex = _regex; if (_type == EXACT) { regex = "^" + "(" + regex + ")" + "$"; } else { regex = ".*" + "(" + regex + ")" + ".*"; } return new RegExp(regex).toAutomaton().intersection(COMMUNITY_FSM); } private  CommunityVar(Type type, String regex, @Nullable Community literalValue); static CommunityVar from(String regex); static CommunityVar from(Community literalCommunity); static CommunityVar other(String regex); @Nonnull Type getType(); @Nullable Community getLiteralValue(); @Override Automaton toAutomaton(); @Override String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override int compareTo(CommunityVar that); static final CommunityVar ALL_COMMUNITIES; }