IDEA-177515 Optional.isPresent() refactoring should not be suggested for ternary with incompatible branch types

This commit is contained in:
Tagir Valeev
2017-08-14 17:51:24 +07:00
parent 04ff01385d
commit b1d286f8f6
2 changed files with 20 additions and 2 deletions
@@ -0,0 +1,14 @@
// "Replace Optional.isPresent() condition with functional style expression" "false"
import java.time.LocalDate;
import java.util.Optional;
public class OptionalTest {
Optional<LocalDate> date = Optional.of(LocalDate.now());
@Override
public String toString() {
final String x = "{date:" + (date.isPres<caret>ent() ? date.get() : "<missing>") + '}';
return x;
}
}