-
Notifications
You must be signed in to change notification settings - Fork 120
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
Added toString, hashcode, and equal methods #450
Conversation
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.
@cammace I like the idea of adding these methods, but as the models and API support grow, this process is manual, tedious, and error-prone.
I'd like to propose an alternative approach to automate this process. My current thinking is to use auto-value-gson to generate all the model classes. This comes with the following benefits out of the box:
- Gson support.
- Creation of
equals
,hashCode
, andtoString
automatically for all models. - Possibility to attach a builder to each method to address Make model constructors more consistent #441
This is a larger change and before we do it I'd like to hear 👍/👎 from @mapbox/android.
My original hesitation for doing this was the overhead that comes with maintaining all these methods. Any means to automate this process sounds great to me. |
Were all tests and Javadoc added to the PR, or is this still pending as per OP? |
I chose not to include test and Javadoc since we plan to switch to AutoValues very soon (which won't require us to test this). |
If you agree that we don't need to add test/javadoc for this, could I get another round of reviews? |
Removing from the 2.2.0 milestone since this isn't an immediate feature needed and most likely the 3.0 release will bring AutoValues which handles this for us. |
Noting here that when using Kotlin Data Classes the compiler automatically derives |
AutoValue works coming in 3.0.0 release which resolves all the things mentioned in this PR, closing. |
This PR adds the standard
toString
hashcode
andequal
methods to model classes. Previously, if you tried comparing two matching objects, it would return false, this fixes that.