mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
26 lines
610 B
Java
26 lines
610 B
Java
// "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 asInteger = index.asInteger();
|
|
if (!seen || asInteger < best) {
|
|
seen = true;
|
|
best = asInteger;
|
|
}
|
|
}
|
|
return seen ? OptionalInt.of(best) : OptionalInt.empty();
|
|
}
|
|
} |