Is it possible to have a data class that has a jav...
# announcements
d
Is it possible to have a data class that has a java class as a property? Was getting an issue when comparing two equivalent data classes. Found out there was no toEquals/toString override on the java class so it was showing the class@hash value. I added those methods to the class and I see the data classes now have the same values but it’s still failing the comparison.
g
This is not a problem of data class and not really Java problem, this class just doesn’t overrider hascode/equal, so comparing by reference, so always return false for any other instance of the same class
d
Yeah I added the override methods to the class and same issue
g
how this method looks like?
d
Yep, hash code used some util instead though so perhaps that is causing a difference, will check the actual hashcode values
g
just check those classes first, create instance and compare
data class just compare by delegating to field class instance