Skip to content

Files

Latest commit

 

History

History
31 lines (22 loc) · 623 Bytes

EqualsAndHashCode.md

File metadata and controls

31 lines (22 loc) · 623 Bytes

Pattern: Missing override for equals() or hashCode()

Issue: -

Description

Checks that if either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.

Here is an example of code that produces a violation:

class SomeClass {
    boolean equals(Object object) {
        // do something
    }
}

And so does this:

class SomeClass {
    int hashCode() {
        return 0
    }
}

Further Reading