I'm trying to use the new @Parcelize annotation added with Kotlin 1.1.4 with a Realm objet containing a RealmList attribute.
@Parcelize
@RealmClass
open class Garage(
var name: String? = null,
var cars: RealmList<Car> = RealmList()
) : Parcelable, RealmModel
As RealmList is not supported by the annotation and assuming that @Parcelize is there specially to avoid creating methods what would be the solution to support RealmList ?
Thanks in advance
EDIT:
Using the power of Type Parcelers and
@WriteWithannotation, it is possible to create a RealmList type parceler that can handle this scenario for you:With the following code:
You can define an interface like this:
Where you'll need to create a specific parceler for the
RealmList<Car>like this:but with that, now you can do the following:
And
This way you don't need to manually write the Parceler logic.
ORIGINAL ANSWER:
Following should work:
As long as you also add following extension functions:
and also