We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Hi Ayaz, you can check on this post how It works, and what's the goal of an immutable class: http://dubedout.eu/2016/05/...
To resume, you can create an object initialized with data and access data from it. You can't modify data once the object is created. You have to create an other object if you want to work with new data. It's an immutable class and it have multiple advantage to work with objects like this.
Have a good day
So what the solution.
Let me explain in details:
I recently came across the concept of using AutoValues (GSON) extension to speed up parsing our json data. We actuall found it parsed our json twice as fast.
But I am missing a point, the data set while using AutoValues is immutable, but often our data sets/models are similar to the json and there are no mappers required.
So if I want to set individual data elements in my model classes this does not look feasible(since we have only abstract getters and no setters. Is there a way around this problem or am I missing a point. I will explain using a sample code of what we do and the similar syntax using AutoValue.
You can still create a new object with your new values instead of changing a variable.
Thanks Vincent
Is there any way that this could work as well with DataBinding? I can not seem to find anything related to it after many Google searches.
Unfortunately I haven't used Android Databinding for now. AutoValue are final objects so I think you should be able to use it as One Way binding but you probably can't do two way binding as autovalue goal is to be immutable.
The thing is that you need an extra Autovalue extension i guess, because you need to add notifyPropertyChanged on the models that are Bindable. Anyway, thanks for the article. Keep up
Actually you can't/should not SET data in an AutoValue/Immutable object as it breaks the nature of it. So it's probably not possible to do it at all.
Very Useful !! Thanks a lot for sharing.
thanks :)
I need setter getter option.But I am not getting.So how we get setter/getter option