Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTrivialLambda/afterMethodRef.java
Tagir Valeev 916cc45005 Constant methods: boxing support
GitOrigin-RevId: 6fa28da7fe823d2e5bea0ecabe1e49e34e55d7b6
2019-12-14 03:44:42 +00:00

29 lines
826 B
Java

// "Fix all 'Constant conditions & exceptions' problems in file" "true"
import org.jetbrains.annotations.*;
import java.util.*;
import java.util.stream.Stream;
public class MethodReferenceConstantValue {
@Contract(value = "!null -> false", pure = true)
public boolean strangeMethod(String s) {
return s == null ? new Random().nextBoolean() : false;
}
public void test(Optional<String> opt) {
X x = (methodReferenceConstantValue, s1) -> false;
Boolean aBoolean = opt.map(s -> false)
.map(o1 -> true)
.map(o -> false)
.orElse(new Random().nextBoolean());
if (opt.isPresent()) {
Stream.generate(() -> true)
.limit(10)
.forEach(System.out::println);
}
}
interface X {
boolean action(@Nullable MethodReferenceConstantValue a, @NotNull String b);
}
}