mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-22 11:29:28 +07:00
GitOrigin-RevId: b6569cf1c45c5de3486d823f37a1426f81d0382d
44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNullByDefault;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Stream;
|
|
|
|
abstract class StreamsNull {
|
|
@NotNullByDefault
|
|
static class Streams {
|
|
@SafeVarargs
|
|
static native <T extends @Nullable Object> Stream<T> concat(Stream<? extends T>... streams);
|
|
}
|
|
|
|
List<String> calc(Stream<Leg> positions, Stream<Leg> leg1, Stream<Leg> leg2, double v) {
|
|
return Streams.concat(
|
|
positions.map(Leg::getInstrument),
|
|
leg1.map(Leg::getInstrument),
|
|
leg2.map(Leg::getInstrument)
|
|
)
|
|
.filter(i -> isInteresting(i, v))
|
|
.toList();
|
|
}
|
|
|
|
List<String> calc2(Stream<Leg> positions, Stream<Leg> leg1, Stream<Leg> leg2, double v) {
|
|
return Streams.concat(
|
|
positions.map(Leg::getInstrument),
|
|
leg1.map(Leg::getInstrument2),
|
|
leg2.map(Leg::getInstrument)
|
|
)
|
|
.filter(i -> isInteresting(<warning descr="Argument 'i' might be null">i</warning>, v))
|
|
.toList();
|
|
}
|
|
|
|
protected abstract boolean isInteresting(@NotNull String instrument,
|
|
double v);
|
|
}
|
|
|
|
interface Leg {
|
|
@NotNull
|
|
String getInstrument();
|
|
@Nullable
|
|
String getInstrument2();
|
|
} |