Skip to content

Commit fd1f4d7

Browse files
committed
use Java 17 language features
1 parent 5045634 commit fd1f4d7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

algorithms/active/sparse/src/main/java/de/learnlib/algorithm/sparse/GenericSparseLearner.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.function.Function;
27-
import java.util.stream.Collectors;
2827

2928
import de.learnlib.algorithm.LearningAlgorithm.MealyLearner;
3029
import de.learnlib.counterexample.LocalSuffixFinders;
@@ -214,8 +213,7 @@ private Word<I> pickSuffix(BitSet remRows) {
214213
}
215214

216215
private void followNode(FringeRow<S, I, O> f, Node<S, I, O> n) {
217-
if (n instanceof Leaf) { // TODO simplify when switching to newer java
218-
final Leaf<S, I, O> l = (Leaf<S, I, O>) n;
216+
if (n instanceof Leaf<S, I, O> l) {
219217
assert l.isUnsplit();
220218
f.leaf = l;
221219
return;
@@ -251,8 +249,7 @@ private void followNode(FringeRow<S, I, O> f, Node<S, I, O> n) {
251249

252250
private Word<O> query(Row<S, I, O> r, Word<I> suf) {
253251
final Word<O> out = oracle.answerQuery(r.prefix.concat(suf));
254-
if (r instanceof FringeRow) { // TODO simplify when switching to newer java
255-
final FringeRow<S, I, O> f = (FringeRow<S, I, O>) r;
252+
if (r instanceof FringeRow<S, I, O> f) {
256253
f.transOut = out.prefix(f.prefix.length()).lastSymbol();
257254
}
258255

@@ -303,9 +300,8 @@ private int moveToCore(FringeRow<S, I, O> f, List<Integer> cellIds) {
303300
* and returns a list containing the observations for all suffixes.
304301
*/
305302
private List<Integer> completeRowObservations(FringeRow<S, I, O> f, List<Integer> cellIds) {
306-
// TODO simplify collector calls when switching to newer java
307-
final List<Word<I>> sufsPresent = cellIds.stream().map(c -> this.cells.get(c).getFirst()).collect(Collectors.toList());
308-
final List<Word<I>> sufsMissing = sufs.stream().filter(s -> !sufsPresent.contains(s)).collect(Collectors.toList());
303+
final List<Word<I>> sufsPresent = cellIds.stream().map(c -> this.cells.get(c).getFirst()).toList();
304+
final List<Word<I>> sufsMissing = sufs.stream().filter(s -> !sufsPresent.contains(s)).toList();
309305
final List<Integer> cellIdsFull = new ArrayList<>(cellIds); // important: copy elements!
310306
sufsMissing.forEach(s -> cellIdsFull.add(getUniqueCellIdx(s, query(f, s))));
311307
return cellIdsFull;

0 commit comments

Comments
 (0)