Finite Automata refactor (#1445)

This commit is contained in:
Grzegorz Piwowarek 2017-03-20 09:15:49 +01:00 committed by GitHub
parent 3accbf8815
commit ed70f6b338
1 changed files with 6 additions and 6 deletions

View File

@ -21,12 +21,12 @@ public final class RtState implements State {
}
public State transit(final CharSequence c) {
for(final Transition t : this.transitions) {
if(t.isPossible(c)) {
return t.state();
}
}
throw new IllegalArgumentException("Input not accepted: " + c);
return transitions
.stream()
.filter(t -> t.isPossible(c))
.map(Transition::state)
.findAny()
.orElseThrow(() -> new IllegalArgumentException("Input not accepted: " + c));
}
public boolean isFinal() {