mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
StreamToLoop: fixed method references unwrap when functional interface type parameter is captured wildcard with upper bound
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class Main {
|
||||
interface Index {
|
||||
int asInteger();
|
||||
}
|
||||
interface IndexSet<S extends Index> {
|
||||
List<S> asList();
|
||||
}
|
||||
|
||||
public static OptionalInt min(IndexSet<?> set) {
|
||||
boolean seen = false;
|
||||
int best = 0;
|
||||
for (Index index : set.asList()) {
|
||||
int i = index.asInteger();
|
||||
if (!seen || i < best) {
|
||||
seen = true;
|
||||
best = i;
|
||||
}
|
||||
}
|
||||
return seen ? OptionalInt.of(best) : OptionalInt.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class Main {
|
||||
interface Index {
|
||||
int asInteger();
|
||||
}
|
||||
interface IndexSet<S extends Index> {
|
||||
List<S> asList();
|
||||
}
|
||||
|
||||
public static OptionalInt min(IndexSet<?> set) {
|
||||
return set.asList()
|
||||
.<caret>stream()
|
||||
.mapToInt(Index::asInteger)
|
||||
.min();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user