Implementations of #equals
should return false
for different types, not
throw.
class Data {
private int a;
@Override
public boolean equals(Object other) {
Data that = (Data) other; // BAD: This may throw ClassCastException.
return a == that.a;
}
}
Suppress false positives by adding the suppression annotation @SuppressWarnings("EqualsUnsafeCast")
to the enclosing element.