-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add ability to specify what fields should make up equals() and hashCode() #128
Comments
Just to clarify, what would be the difference between this, and simply On Thu, Sep 10, 2015 at 6:18 PM Anwar C [email protected] wrote:
|
In my use case, I use https://projectlombok.org/ annotations to add equals and hashCode. What I have been running into with the annotation is that , people use a blanket @EqualsAndHashCode annotations on classes without being explicit about the fields. My goal is, with the help of equalsverifier, to make sure that if we specify fields on the above specified annotation, only those are included in the equals and hashCode. Later on , if some one adds or removes a field, there better be a failing test. Hope it makes sense. |
Thanks for the clarification. So if I understand you correctly, you want to specify exactly which fields are used. Then if somebody adds a field without also adding it to the test, EV will fail, and if someone removes a field without also removing it from the test, EV will also fail. I like that idea, and I'll probably add that in a future version. I'm currently working on a few big things so it probably won't be the next one, though. Probably the one after that. |
Would you accept a PR for this feature ? |
Well, I would appreciate that very much :)! However, you should know that I'm preparing a 2.0 version in the current master branch. One of the things I've already implemented there is issue #65, that makes If you don't mind all that, then I very much appreciate your PR, and I'll include it in the 2.0 release. Otherwise, I'll add it in 2.1. |
I've included this in version 2.0, which has just been released! |
Just like
EqualsVerifier.allFieldsShouldBeUsedExcept()
, it would be nice to haveEqualsVerifier.onlyTheseFields(String ...fieldNames)
. The limitation to the former is that, for a class with lot of fields, it's tedious to specify the exclusions.The text was updated successfully, but these errors were encountered: