// haven't started with this state yet
states.add(state);
if (state.isFinal()) {
if (!state.getTransitions().isEmpty()) {
throw new DefinitionError("Some events defined for final State: " + state);
}
} else {
if (state.getTransitions().isEmpty()) {
throw new DefinitionError("No events defined for non-final State: " + state);
}
}
for (Map.Entry<Event<C>, State<C>> e : state.getTransitions().entrySet()) {
Event<C> event = e.getKey();
State<C> stateTo = e.getValue();
if (state.equals(stateTo)) {
throw new DefinitionError("Circular Event usage: " + event);
}
validate(stateTo);
}
}
}