# Parcelable

**URL:** <https://discuss.kotlinlang.org/t/parcelable/1427>\
**Category:** Android\
**Created:** [January 21, 2016, 8:32am UTC](https://discuss.kotlinlang.org/t/parcelable/1427 "2016-01-21T08:32:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsvoronin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/dsvoronin/32/1478_2.png) [@dsvoronin](https://discuss.kotlinlang.org/u/dsvoronin)\
**Post date:** [January 21, 2016, 8:32am UTC](https://discuss.kotlinlang.org/t/parcelable/1427/1 "2016-01-21T08:32:59Z")

</div>

Parcelable classes need to implement two methods, and static field CREATOR [http://developer.android.com/reference/android/os/Parcelable.html](http://developer.android.com/reference/android/os/Parcelable.html)

Its quite the same as `data` class concept.  
Can it be implemented the same way?

parcelable class MyClass(val …)?

There are plenty of annotation processing code generation tools, but it will be super cool to implement it “inside” kotlin

I would love to contribute such thing but need some starting points and language designers accept

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [January 21, 2016, 10:18am UTC](https://discuss.kotlinlang.org/t/parcelable/1427/2 "2016-01-21T10:18:06Z")

</div>

We are trying to keep the language platform-independent. Adding `parcelable` as a built-in modifier does not seem sensible, although the use case is very credible.

---

<div class="post-metadata">

**Author:** ![dsvoronin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/dsvoronin/32/1478_2.png) [@dsvoronin](https://discuss.kotlinlang.org/u/dsvoronin)\
**Post date:** [January 21, 2016, 10:33am UTC](https://discuss.kotlinlang.org/t/parcelable/1427/3 "2016-01-21T10:33:58Z")

</div>

Yes, i understand that.  
Does it mean that we need android-specific compiler, ide plugin that aware of environment and so on?

Can it somehow be solved with kotlin-android-extensions?

---

<div class="post-metadata">

**Author:** ![dwallach](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/dwallach/32/1657_2.png) [@dwallach](https://discuss.kotlinlang.org/u/dwallach)\
**Post date:** [January 21, 2016, 3:51pm UTC](https://discuss.kotlinlang.org/t/parcelable/1427/4 "2016-01-21T15:51:41Z")

</div>

This is something worth generalizing. Parcelable for Android. Protobufs for other things. JSON or XML for yet others. Maybe a good place to look for inspiration is Go, where classes implement [a small interface](https://golang.org/pkg/encoding/) and are then compatible with a variety of different encoders.

---

<div class="post-metadata">

**Author:** ![norswap](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/norswap/32/1737_2.png) [@norswap](https://discuss.kotlinlang.org/u/norswap)\
**Post date:** [January 21, 2016, 6:39pm UTC](https://discuss.kotlinlang.org/t/parcelable/1427/5 "2016-01-21T18:39:47Z")

</div>

What about forcing the companion object to inherit from the companion object of its supertypes through delegation?

The problem in this case is that CREATOR is a field, not a method, and delegation cannot handle that.

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [January 21, 2016, 9:15pm UTC](https://discuss.kotlinlang.org/t/parcelable/1427/6 "2016-01-21T21:15:16Z")

</div>

Take a look at [DataParcel](https://github.com/grandstaish/DataParcel) — An annotation processor to automatically generate Parcelable wrappers for Kotlin Data Classes.

[quote=Bradley Campbell]  
For any of the Android developers in here, I’m hoping some of you are interested in my annotation processor that generates Parcelable wrapper classes for kotlin data classes. I’m looking for feedback, bugs, questions, or even pull requests. It’s not released yet officially so I’d appreciate it not being posted to Reddit unless there’s a disclaimer. [/quote]
