java.util.Objects.equals()
, which is available since JDK 1.7.
For example:
a == b || a != null && a.equals(b)
a != null ? a.equals(b) : b == null
Replacing expressions like
with
a != null && a.equals(b)
slightly changes the semantics,
but if that's what you need there's a check box for that in the inspection settings.
Objects.equals(a, b)
This inspection only reports if the language level of the project or module is 7 or higher