Stream API migration: support nested anyMatch

This commit is contained in:
Tagir Valeev
2016-10-03 12:43:44 +07:00
parent 086ac8f4f2
commit b53646340b
4 changed files with 158 additions and 45 deletions
@@ -0,0 +1,9 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
public Integer[] testNestedAnyMatch(List<List<String>> data) {
return data.stream().filter(list -> list.stream().anyMatch(str -> !str.isEmpty())).map(List::size).toArray(Integer[]::new);
}
}
@@ -0,0 +1,18 @@
// "Replace with toArray" "true"
import java.util.*;
public class Main {
public Integer[] testNestedAnyMatch(List<List<String>> data) {
List<Integer> result = new ArrayList<>();
for (List<String> list : d<caret>ata) {
for (String str : list) {
if (!str.isEmpty()) {
result.add(list.size());
break;
}
}
}
return result.toArray(new Integer[result.size()]);
}
}
@@ -0,0 +1,18 @@
// "Replace with toArray" "false"
import java.util.*;
public class Main {
public Integer[] testNestedAnyMatch(List<List<String>> data) {
List<Integer> result = new ArrayList<>();
for (List<String> list : d<caret>ata) {
for (String str : list) {
if (!str.isEmpty()) {
result.add(str.length());
break;
}
}
}
return result.toArray(new Integer[result.size()]);
}
}