Back to Intellij Community

OptionalIsPresent

java/java-impl/resources/inspectionDescriptions/OptionalIsPresent.html

2025.3-rc-2303 B
Original Source

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);