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

Improve the way Equals and Hashcode are generated #241

Merged
merged 2 commits into from
Sep 28, 2014
Merged

Improve the way Equals and Hashcode are generated #241

merged 2 commits into from
Sep 28, 2014

Conversation

jharmelink
Copy link
Contributor

No description provided.

Moved hashCode and equals generation steps after additional properties generation so the additional properties will be used in the hashCode and equals generation
@joelittlejohn
Copy link
Owner

Excellent. Thanks for looking at this Jan, every user will benefit from this.

Could you squash these changes into one commit and try to remove any unnecessary formatting?

One final thing - do you have any comment on the backwards compatibility of this change? Is the behaviour (e.g. where subclasses are concerned) functionally equivalent to the original reflectionHashCode and reflectionEquals calls? If not, this may not be a blocker, but we should add an extra note to the release notes.

@jharmelink
Copy link
Contributor Author

OK, no problem. I'll look into it tomorrow.

@joelittlejohn joelittlejohn added this to the 0.4.6 milestone Sep 25, 2014
@joelittlejohn joelittlejohn changed the title Improve the way Equals and Hashcode are generated. #150 Improve the way Equals and Hashcode are generated Sep 25, 2014
@joelittlejohn joelittlejohn merged commit 701ea90 into joelittlejohn:master Sep 28, 2014
@jharmelink
Copy link
Contributor Author

Sorry I couldn't look into it before you merged it. The past few weeks have ben rather hectic. I'm also thinking about making the fields to use in the hashcode and equals generation configurable in the future. What do you think of that idea?

@steowens
Copy link

Been away for quite some time and apologies in advance from the peanut gallery. Personally I like the idea of having a configurable set of options on the way that hashcode and equals are built. Trying to keep them functionally equivalent to Reflections hashcode builder and equals is not in my opinion desirable. There are many times where you would want to generate pojo classes for which equality is based on only a subset of the properties of the pojo. For example when using a subset of properties as a unique key to index the pojo when storing in a mongo reposotiry.

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.

3 participants