HomePhabricator

Make toString(), hashCode(), equals() and friends final in AutoValue classes

Authored by Edwin Kempin <ekempin@google.com> on Jul 1 2019, 2:10 PM.

Description

Make toString(), hashCode(), equals() and friends final in AutoValue classes

Developers usually don't look at the classes that AutoValue generates,
but at the hand-written classes. If the hand-written classes implement
toString(), hashCode(), equals() etc, AutoValue doesn't override them.
To make this more clear to readers of the hand-written classes
ErrorProne suggests to make these methods final.

See https://errorprone.info/bugpattern/AutoValueFinalMethods

Enable this check at ERROR severity to prevent future occurrences.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I972e8e8f9339b811c78157abef771b8c32be079c

Event Timeline

David Ostrovsky <david.ostrovsky@gmail.com> committed rGERRITDEPLOY7360297a666d: Make toString(), hashCode(), equals() and friends final in AutoValue classes (authored by Edwin Kempin <ekempin@google.com>).Apr 27 2020, 4:27 AM