mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Test for IDEA-375523 False positive "Argument might be null" with Guava Streams
GitOrigin-RevId: b6569cf1c45c5de3486d823f37a1426f81d0382d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d5653fd75b
commit
02a063f866
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user