-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Data needs a warning when either equals() or hashCode() is already implemented #548
Comments
👤 ericlef 🕗 May 02, 2013 at 15:27 UTC I was in the process of Lombokifying a bean, step by step. This meant removing the hashCode(), leaving equals() as it was, and counting on Lombok to generate an appropriate hashCode(). It only became clear when, on a whim, we add @ EqualsAndHashCode to our class. This gave us an appropriate warning ("Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated).") I would like to see the same warning on @ Data. Side note: I tried using delombok to figure out the issue. However, in order to make my class compile without the whole classpath, I removed equals() temporarily. I saw the code generated by delombok, so I was quite sure that nothing was wrong... Of course, I immediately restore equals() and didn't make the connection with the problem at all. ;-) |
👤 reinierz 🕗 May 06, 2013 at 18:59 UTC This isn't a lombok bug, it's a bug in our specs, because this is dumb but specified behaviour. We are going to re-spec the behaviour to this new rule: If using @ Data and you have only one of the pair of equals/hashCode methods implemented, you get a warning. If you have 0 of the 2, they get added. If you have both, they aren't, and you get no warning. That's how it works now except for the weird '1 is there but the other one is missing' case that you ran into. |
👤 reinierz 🕗 May 06, 2013 at 20:09 UTC Fixed; will be in next release. |
👤 ericlef 🕗 May 06, 2013 at 22:20 UTC Thanks! |
End of migration |
Migrated from Google Code (issue 513)
The text was updated successfully, but these errors were encountered: