NFA implements Serializable { static String generateStateName(final String name, final int index) { Matcher matcher = namePattern.matcher(name); if (matcher.matches()) { return matcher.group(1) + index + matcher.group(2); } else { return name + "_" + index; } } NFA(final TypeSerializer<T> eventSerializer, final long windowTime); Set<State<T>> getStates(); void addStates(final Collection<State<T>> newStates); void addState(final State<T> state); Collection<Map<String, T>> process(final T event, final long timestamp); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testStateNameGeneration() { String expectedName1 = "a[2]"; String expectedName2 = "a_3"; String expectedName3 = "a[][42]"; String generatedName1 = NFA.generateStateName("a[]", 2); String generatedName2 = NFA.generateStateName("a", 3); String generatedName3 = NFA.generateStateName("a[][]", 42); assertEquals(expectedName1, generatedName1); assertEquals(expectedName2, generatedName2); assertEquals(expectedName3, generatedName3); }