StreamToLoop: support condition inside flatMap

This commit is contained in:
Tagir Valeev
2016-12-27 14:40:01 +07:00
parent 96cf01152f
commit 54eb6ce6af
4 changed files with 84 additions and 2 deletions
@@ -0,0 +1,16 @@
// "Replace Stream API chain with loop" "true"
import java.util.*;
import java.util.stream.*;
public class Main {
public void test(List<List<String>> list) {
for (List<String> lst : list) {
if (lst != null) {
for (String s : lst) {
System.out.println(s);
}
}
}
}
}
@@ -0,0 +1,10 @@
// "Replace Stream API chain with loop" "true"
import java.util.*;
import java.util.stream.*;
public class Main {
public void test(List<List<String>> list) {
list.stream().flatMap(lst -> lst == null ? Stream.empty() : lst.stream()).<caret>forEach(System.out::println);
}
}