https://kotlinlang.org logo
Title
m

mg6maciej

04/13/2017, 2:27 PM
@vyacheslav.gerasimov Are you planning to support all the cases?
v

vyacheslav.gerasimov

04/13/2017, 2:29 PM
Yes, what cases would you like to be supported?
m

mg6maciej

04/13/2017, 2:30 PM
It was a trick question 😉
Supporting all basic types is not simple.
Take a look at what generated code could like like for `LinkedHashMap<char[][], List<TreeSet<Bundle>>>`: https://github.com/mg6maciej/hrisey/blob/develop/test/transform/resource/after-delombok/ParcelableUberComplexUselessType.java
For a more descriptive way of showing what I consider basic types, you may take a look here: https://github.com/mg6maciej/hrisey/wiki/Parcelable#details
And even there is a difference in generated code when field's type is final
Parcelable
compared to when it is not. Basically you can avoid parceling class name FQCN and when reading avoid using
Class.forName
and friends (talking about what happens internally in
Parcel
class).
v

vyacheslav.gerasimov

04/13/2017, 2:41 PM
generated code for
LinkedHashMap<char[][], List<TreeSet<Bundle>>>
looks scary to me, i think first version will not handle complex types, such as collection of collection
thanks for info
m

mg6maciej

04/13/2017, 2:42 PM
Yes, it looks scary. I would never use such structure in my own code. And even if I did I would never handwrite code like this.
It is code generated by Lombok, so user never sees it.
But it is the most optimal way of parcelling stuff at the same time.
Generally trying to avoid hard limit of 1MB serialized data and even trying to make sure it's as low as possible (you may see UI lags after 100kB).
@vyacheslav.gerasimov Just noticed there was a plugin for that https://github.com/nekocode/android-parcelable-intellij-plugin-kotlin