mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-18 08:50:57 +07:00
Keeping the block does not work correctly for blocks with return statement GitOrigin-RevId: d14e22e793840d74957928a8d7748275db4929ef
52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
|
|
|
import java.util.*;
|
|
import java.util.stream.*;
|
|
|
|
class X {
|
|
record N(N parent, List<N> children, String whatever) {}
|
|
|
|
private static N reproducer(N parent, String frame) {
|
|
return parent.children.<caret>stream()
|
|
.filter(child -> child.whatever.equals(frame))
|
|
.findAny()
|
|
.orElseGet(() -> {
|
|
N result = new N(parent, new ArrayList<>(), frame);
|
|
parent.children.add(result);
|
|
return result;
|
|
});
|
|
}
|
|
|
|
void testMap(List<String> list) {
|
|
List<List<String>> newList = list.stream()
|
|
.map(item -> {
|
|
List<String> result = new ArrayList<>();
|
|
result.add(item);
|
|
result.add(item + item);
|
|
return result;
|
|
})
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
void testFilter(List<String> list) {
|
|
List<String> newList = list.stream()
|
|
.filter(s -> {
|
|
boolean result = false;
|
|
if (s.isEmpty()) result = true;
|
|
return result;
|
|
})
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
private static List<String> getStrings(List<String> test) {
|
|
return test.stream()
|
|
.collect(()->{
|
|
ArrayList<String> objects = new ArrayList<>();
|
|
objects.add("1");
|
|
return objects;
|
|
}, (strings, string) -> {
|
|
System.out.println("1");
|
|
strings.add(string);
|
|
}, (strings, strings2) -> strings.addAll(strings2));
|
|
}
|
|
} |