I have a data class like this
data class Person(val id: Long = BaseDataContract.BaseData.UNDEFINED_ID.toLong(),
.....
val personConsents: ArrayList<PersonConsent> = ArrayList<PersonConsent>())
I have two copies of the object:
person = originalPerson.copy()
Then I change the elements of personConsents for the object person - I add/delete/edit them.
But by some reason I see that the same changes are happening in originalPerson object which I don't want to be. originalPerson is not supposed to be changed at all.
Suspect there is something with ArrayList references, but need your advice what i can do? At the end I need to compare two objects likefun dataChanged(): Boolean = originalPerson != person
bu it doesn't work when ArrayList is changing.