mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
Stream API migration: support nested anyMatch
This commit is contained in:
+9
@@ -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);
|
||||
}
|
||||
}
|
||||
+18
@@ -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()]);
|
||||
}
|
||||
}
|
||||
+18
@@ -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()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user