Robert St. John
12/05/2022, 5:38 PMequals()
and hashCode()
methods. i also would prefer that all properties of the class are immutable, so the class is more like a functional style data type, and i would appreciate having kotlin auto-generate the copy()
method with the selective override parameters. however, i can't seem to achieve all these things at the same time because if i create the data class with only the primary key property in the primary constructor, Room needs public setters for the rest of the properties, and i will not get the copy()
method with parameters for all the non-constructor properties. if i put all immutable properties in the primary constructor, i lose the desired equals()
and hashCode()
semantics and i also have concerns about the overhead of that many properties participating in those methods. has anyone tried/been able to achieve this with a data class? my current solution is a standard class with all immutable properties in the primary constructor, and a copy constructor that takes a source instance argument, then individual override parameters for all the properties, but that's a bit of headache and error-prone to maintainpsh
12/05/2022, 5:47 PMpsh
12/05/2022, 5:49 PMRobert St. John
12/05/2022, 5:53 PM