I have created a small test app for this issue here: (https://github.com/Winghin2517/EpoxyExample2).
I would like to pass a list of objects into the epoxy controller so that I can generate a graph. I have however encountered this error when building the app:
error: Epoxy Processor Exception: Type in Iterable does not implement hashCode. Type: kwaai.com.exampleepoxy_hashcodeequals.GraphData (View Prop {view='HeaderView', name='setLineChart', type=java.util.LinkedList}) Epoxy requires every model attribute to implement equals and hashCode so that changes in the model can be tracked. If you want the attribute to be excluded, use the option 'DoNotHash'. If you want to ignore this warning use the option 'IgnoreRequireHashCode'
I think it is because I using the @ModelProp on a List of Objects (LinkedList of GraphDataFeed) and not on a primitive type as per the example app from Epoxy.
@ModelProp
public void setLineChart(LinkedList<GraphData> graphDataFeed) { }
So I folllowed the options and modified my @ModelProp to reflect this:
@ModelProp(options = ModelProp.Option.IgnoreRequireHashCode)
After the change the app builds and runs correctly. You can see the graph below.
However, I do not want to ignore the attribute as I understand Epoxy uses Diffing to update the models in the recyclerview: https://github.com/airbnb/epoxy/wiki/Diffing
Ignoring the attribute might mean that my models do not get updated correctly in the recyclerview. In the guidance material here (https://github.com/airbnb/epoxy/wiki/Epoxy-Models#annotations), I see it says:
A model's state is determined by its equals and hashCode implementations, which is based on the value of all of the model's properties.
This state is used in diffing to determine when a model has changed so Epoxy can update the view.
These methods are generated so you don't have to created them manually.
Why are these methods not generated for me then and if they are not generated, how do I generate these methods myself to get rid of the error?