Consider annotation to only use a field in the hashcode and equals
aballano opened this issue · 4 comments
Same idea, but the other way around, something like @OnlyHashEquals or @HashEqualsId to only mark the fields to appear in the hashCode and equals. This would be really useful specially when dealing with models that already have an id field so you wouldn't have to put "@IgnoreHashEquals" in all other fields.
@REggar If you agree to include it here I could make a PR today :)
@Shyish How about @IncludeHashEquals
? If the annotation is included in an AutoValue model, it will only include the fields marked with the annotation in the hashCode and equals implementations.
@REggar I'm working on it ATM, but for some reason the test for AutoValueIgnoreHashEqualsExtensionTest doesn't pass, does it work for you? If not I'll try to take a look, but might be more complicated than I though
@Shyish
Tests do pass on my local and on CI. Run ./gradlew test
and let me know the output.
Added in latest release