-
Notifications
You must be signed in to change notification settings - Fork 882
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
Use java.util.Objects to implement equals, hashCode #294
Conversation
This creates a bit more garbage because it needs to load things into an array. I'm guessing we're balancing against jar size? How much does this help that? |
This uses |
Cool, I missed that! |
} | ||
if (!Objects.equals(booleanMember(), other.booleanMember()) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we could just do return Object.equals() && Object.equals() & ...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 sounds good
Updated |
memberModels.stream() | ||
.skip(1) | ||
.forEach(m -> adder.accept("&&", m)); | ||
memberEqualsStmt.add(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the PoetCollectors.toDelimitedCodeBlock make this a bit easier to implement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Didn't know that was there. Done
Description
Use
java.util.Objects
to implementsequals()
andhashCode()
.Motivation and Context
Should cut down on generated file size.
Testing
Updated reference tests.
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsLicense