'SonarLint: Remove the literal "false" boolean value

I get "Remove the literal "false" boolean value." error for the following statement, but I am not sure if there is a possibility to remove false. Any idea?

final boolean isDisabled = productMap.get(product.getUuid()) != null ?
                    productMap.get(product.getUuid()) : false;


Solution 1:[1]

Probably Sonar complies about having a ternary operation with a literal for a boolean operation.

Checking your code I assume productMap values are Boolean, not boolean, thats why you are null checking.

In that case consider the following code for safe unboxing a nullable Boolean

final boolean isDisabled = Boolean.TRUE.equals(productMap.get(product.getUuid()));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ezequiel