IDEA-179490 "Can be replaced with single expression in functional style" in Java fails when field name matches class name

This commit is contained in:
Tagir Valeev
2017-09-26 09:44:21 +07:00
parent fa6bbd0b5d
commit b2df7a760a
4 changed files with 47 additions and 7 deletions
@@ -0,0 +1,18 @@
// "Replace Optional.isPresent() condition with functional style expression" "true"
import java.util.Optional;
public class Test {
private Power power;
interface Power {
static Optional<Power> parseValue(String value) {
return Optional.empty();
}
}
void testOpt(String powerValue) {
Optional<Power> optPower = Power.parseValue(powerValue);
optPower.ifPresent(power1 -> power = power1);
}
}
@@ -0,0 +1,20 @@
// "Replace Optional.isPresent() condition with functional style expression" "true"
import java.util.Optional;
public class Test {
private Power power;
interface Power {
static Optional<Power> parseValue(String value) {
return Optional.empty();
}
}
void testOpt(String powerValue) {
Optional<Power> optPower = Power.parseValue(powerValue);
if (optPower<caret>.isPresent()) {
power = optPower.get();
}
}
}