Is there a way to hook into a data class' copy met...
# announcements
n
Is there a way to hook into a data class' copy method? For example:
Copy code
data class Example(val name: String?)
Let's say I have an
Example("")
, but I want blank strings to be null. I can do:
Copy code
ex.copy(name = if (name.isBlankOrNull()) null else name)
But this requires hard coding. Is there a safe way to process all the fields like this?
a
Nope, there is currently no way to change any of the generated methods