https://kotlinlang.org logo
Title
m

miha-x64

09/27/2017, 5:12 PM
About @Parcelize. If I understood correctly, Kotlin compiler can implement Parcelable in existing class. But what about parcelable wrapper, e. g.
class ParcelSomething(val something: Something) : Parcelable {...
, where
Something
is not parcelable itself?
d

damian

09/27/2017, 5:17 PM
There is something for a
CustomParceler
annotation in the KEEP, but it doesn't look like it's been implemented [yet]: https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md#per-property-and-per-type-parcelers
m

miha-x64

09/27/2017, 5:17 PM
'Custom' means 'hand-written', isn't it?
d

damian

09/27/2017, 5:18 PM
What would the alternative to hand-written be? EDIT: Oh I see what you mean. No, the compiler can't implement
Parcelable
on arbitrary existing classes. It can only do so for your own classes annotated with
@Parcelize
.
Also, you could implement a
Parceler
in your companion object if you only need to parcel the whole class and not define them generally on a per-type basis: https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md#custom-parcelables