Inspectopedia
 
2024.3

Non functional style 'Optional.isPresent()' usage

Warning
New
Last modified: 03 December 2024

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:

After the quick-fix is applied:

This inspection depends on the Java feature 'Stream and Optional API', which is available since Java 8.