This function violates the contract that it must compare its parameter with null.
The Java standard requires that implementations of Object.equals()
, Comparable.compareTo()
, and Comparator.compare()
must return a specified value if their parameters are null. Failing to follow this contract may result in unexpected behavior.
Example 1: The following implementation of the equals()
method does not compare its parameter with null.
public boolean equals(Object object)
{
return (toString().equals(object.toString()));
}
[1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 398