mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
IDEA-167580 Uncompilable code after conversion Stream -> Loop with generics
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
public class Main {
|
||||
static Predicate<String> nonEmpty = s -> s != null && !s.isEmpty();
|
||||
|
||||
@@ -16,6 +20,24 @@ public class Main {
|
||||
return count;
|
||||
}
|
||||
|
||||
private Set<Identifier> test(Set<Identifier> identifiers) {
|
||||
Set<Identifier> set = new HashSet<>();
|
||||
Predicate<? super Identifier> predicate = isReady(identifiers);
|
||||
for (Identifier identifier : identifiers) {
|
||||
if (predicate.test(identifier)) {
|
||||
set.add(identifier);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
private Predicate<? super Identifier> isReady(Set<Identifier> identifiers) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class Identifier {
|
||||
}
|
||||
|
||||
private static long testStreamOfFunctions(List<Predicate<String>> predicates, List<String> strings) {
|
||||
long count = 0L;
|
||||
for (Predicate<String> pred : predicates) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
public class Main {
|
||||
static Predicate<String> nonEmpty = s -> s != null && !s.isEmpty();
|
||||
|
||||
@@ -10,6 +13,17 @@ public class Main {
|
||||
return strings.stream().filter(nonEmpty).cou<caret>nt();
|
||||
}
|
||||
|
||||
private Set<Identifier> test(Set<Identifier> identifiers) {
|
||||
return identifiers.stream().filter(isReady(identifiers)).collect(toSet());
|
||||
}
|
||||
|
||||
private Predicate<? super Identifier> isReady(Set<Identifier> identifiers) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class Identifier {
|
||||
}
|
||||
|
||||
private static long testStreamOfFunctions(List<Predicate<String>> predicates, List<String> strings) {
|
||||
return predicates.stream().filter(pred -> pred != null)
|
||||
.flatMap(p -> strings.stream().filter(p)).count();
|
||||
|
||||
Reference in New Issue
Block a user