mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
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:
+18
@@ -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);
|
||||
}
|
||||
}
|
||||
+20
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user