Finite Automata refactor (#1445)
This commit is contained in:
parent
3accbf8815
commit
ed70f6b338
|
@ -21,12 +21,12 @@ public final class RtState implements State {
|
||||||
}
|
}
|
||||||
|
|
||||||
public State transit(final CharSequence c) {
|
public State transit(final CharSequence c) {
|
||||||
for(final Transition t : this.transitions) {
|
return transitions
|
||||||
if(t.isPossible(c)) {
|
.stream()
|
||||||
return t.state();
|
.filter(t -> t.isPossible(c))
|
||||||
}
|
.map(Transition::state)
|
||||||
}
|
.findAny()
|
||||||
throw new IllegalArgumentException("Input not accepted: " + c);
|
.orElseThrow(() -> new IllegalArgumentException("Input not accepted: " + c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFinal() {
|
public boolean isFinal() {
|
||||||
|
|
Loading…
Reference in New Issue