09/16/2018, 12:34 PM
I’ve been wondering, why there is no ComponentN interfaces in Kotlin. There are already componentN() methods generated for each data class and this little addition would help to work with data classes as just named tuples in a generic way. I came up with some ideas of application of that: 1) Generic mappers for similar similar objects (for example, we have
with annotations for our ORM and stuff and ordinary
and we can map between them easily) 2) Unwrapping data classes to destructive function calls (like spread operator for arrays) 3) Generic serialization/deserialization for formats presolving order (like Android’s Parcelable) 4) Generic encryption/decryption 5) Pattern-matching for when (using
in Pattern(...)
and matcher like in Mockito (any(), eq(), etc.) 6) Hotswap between tuples and data-classes when you need to process your data 7) Generic
data classes Any concerns? I’m about to fire a KEEP but doubt that it wasn’t discussed before