We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3accbf8 commit ed70f6bCopy full SHA for ed70f6b
1 file changed
algorithms/src/main/java/com/baeldung/automata/RtState.java
@@ -21,12 +21,12 @@ public RtState(final boolean isFinal) {
21
}
22
23
public State transit(final CharSequence c) {
24
- for(final Transition t : this.transitions) {
25
- if(t.isPossible(c)) {
26
- return t.state();
27
- }
28
29
- 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));
30
31
32
public boolean isFinal() {
0 commit comments