do data classes support deep equals (a is equal to b iff the entire object graph that starts at a and b are equal) ?
s
spand
07/03/2020, 6:12 AM
It will call
equals
on its parts if thats what you mean.
r
rrva
07/03/2020, 6:27 AM
in nested structures
m
Milan Hruban
07/03/2020, 6:33 AM
data class equals will call equals method on all of it's properties (like was said above). If the properties (and their properties...) have correctly implemented equals, then it does work as you would expect
Milan Hruban
07/03/2020, 6:34 AM
Best would be to read docs about how equals work, how data class generates equals and try it out
r
rrva
07/03/2020, 9:12 AM
I did verify my desired behavior with a couple of unit tests
rrva
07/03/2020, 9:12 AM
I just had a gut feeling that equals was not “deep” since some other languages do not help you with this out of the box. With data classes it seems to be fine just out of the box