Override Both Equals And Hashcode

Impact area

Manageability

Severity

Medium

Affected element

Apex Class

Rule ID

SF-OVERRIDE-BOTH

Impact

Override equals() and not override hashCode() can result in unexpected behavior when your class is in conjunction with all hash-based collections.

Remediation

You must override hashCode() in every class that overrides equals().

Time to fix

30 min

References

This rule is linked to OverrideBothEqualsAndHashcode

What's here


Related content

Apex Page rules

Salesforce rules




Last modified on Nov 13, 2023