-
Notifications
You must be signed in to change notification settings - Fork 101
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Opt out a property for equals/hashCode #54
Comments
Just a note: dropping fields from equality makes it very easy to write broken unit tests (and hard to write good ones). If you find yourself wanting this feature, consider first whether you actually want a different collection type (typically a Map rather than a Set, for instance), or if you can use an explicit field-ignoring Comparator in the parts of the code that need it. Otherwise, 👍 this issue, and consider adding a comment explaining your situation! |
@alicederyn sounds like you aren't a fan of the premise but are okay with the feature. In other words, someone could provide a PR for this feature that could be accepted. For a situation I find myself in: |
I would like the ability to define a value class where a certain field isn't included in equality.
For example, I recently came to a need to define a helper class that wraps the input object T and its original index in the input List.
I want IndexedFoo's equality to be based on the index, but not the Foo object.
The text was updated successfully, but these errors were encountered: