mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
StreamToLoopInspection: disable for raw types (IDEA-163493), disable for unresolved method references
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
interface Role {}
|
||||
class FooRole {
|
||||
public Role[] getRoles(Predicate<Object> p, List<Role> roles) {
|
||||
List<Role> list = new ArrayList<>();
|
||||
for (Role role : roles) {
|
||||
if (p.test(role)) {
|
||||
list.add(role);
|
||||
}
|
||||
}
|
||||
return list.toArray(new Role[0]);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
interface Role {}
|
||||
class FooRole {
|
||||
public Role[] getRoles(Predicate<Object> p, List<Role> roles) {
|
||||
return roles.stream().filter(p).toArr<caret>ay (Role[]::new);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace Stream API chain with loop" "false"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
interface Role {}
|
||||
class FooRole {
|
||||
public Role[] getRoles(Predicate p, List<Role> roles) {
|
||||
return roles.stream().filter(p).toArr<caret>ay (Role[]::new);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace Stream API chain with loop" "false"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class Main {
|
||||
private static List<Object> test(List<List> list) {
|
||||
return list.stream().<Object>flatMap(List::stream).coll<caret>ect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(asList(asList("a", "d"), asList("c", "b"))));
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace Stream API chain with loop" "false"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class Main {
|
||||
private static int test(List<String> list) {
|
||||
return list.stream().mapToInt(Blahblah::size).su<caret>m();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(asList("a", "b", "c")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user