Skip to content
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

[Feature request] @EqualsAndHashCode Flexibility for rank properties for equal/hashcode method #2485

Merged
merged 2 commits into from
Jun 11, 2020
Merged

Conversation

samukce
Copy link
Contributor

@samukce samukce commented Jun 5, 2020

Given some special cases where we need to explicitly order the comparation fields for performance improvement, I have applied the same idea that we have for @ToString.Include(rank = -1). ie.: @EqualsAndHashCode.Include(rank = -1)

Also, there are some discussions related to this here (#1543) about the Equals algorithm and performance. So, given this flexibility can help me with some special cases and I believe that can be helpful for more people too. Let me know what you think folks.

@samukce samukce changed the title [Feature request] @EqualsAndHashCode Flexibility for rank properties for equal [Feature request] @EqualsAndHashCode Flexibility for rank properties for equal/hashcode method Jun 5, 2020
@samukce
Copy link
Contributor Author

samukce commented Jun 10, 2020

hello @rspilker , could you take a look at this PR? This improvement would help me given that I use to need to tunning java code and be able to handle those equals configuration through Lombok would be helpful and keep the code clean.

@rspilker rspilker merged commit db59aa4 into projectlombok:master Jun 11, 2020
@rspilker
Copy link
Collaborator

Great job!

I love that you've even added a test case, and added you name the the AUTHORS file.

@rspilker
Copy link
Collaborator

This also opens the door to give primitives as default rank. We could document them to have a default of 1000 for instance.

@samukce
Copy link
Contributor Author

samukce commented Jun 11, 2020

That sounds promising @rspilker I will see if I can submit some PR with this idea also.

@samukce samukce deleted the equals-and-hashcode-order branch June 11, 2020 20:12
@rspilker
Copy link
Collaborator

I'm nearly done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants