While using this method does not create any problem, I consider it a code smell because this method was designed to be used along with lambdas and not for other usages
Description of the method from the java docs :
API Note:
This method exists to be used as a
Predicate
,filter(Objects::isNull)
- snippet of Noncompliant Code
if (Objects.isNull(object)) {
}
- snippet of Compliant Code (fixing the above noncompliant code)
if (object == null) {
}
- exceptions to the Noncompliant Code, i.e. conditions in which the noncompliant code should not raise an issue so that we reduce the number of False Positives.
This should not be marked as a code smell when used within java streams.Example :
list.stream().filter(Object::isNull)
Java docs : Objects (Java Platform SE 8 )