Non functional style 'Optional.isPresent()' usage
Reports Optional
expressions used as if
or conditional expression conditions, that can be rewritten in a functional style. The result is often shorter and easier to read.
Example:
if (str.isPresent()) str.get().trim();
After the quick-fix is applied:
str.ifPresent(String::trim);
This inspection only reports if the language level of the project or module is 8 or higher.
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023