auto-value-parcel
auto-value-parcel copied to clipboard
Check if objects inside lists can be written into parcel
This is kind of question/feature request.
In short question is: can we somehow check if values contained inside our List
members can be written into parcel?
So imagine we have some value class:
@AutoValue
abstract class ExampleClass implements Parcelable {
abstract int intMember();
@NonNull
abstract String stringMember();
}
Nothing special. If we add some non-parcelable member to our ExampleClass
we'll got error message at compile time which is super cool. Unfortunately this is not true if we'll add List<NonParcelableClass>
:
@AutoValue
abstract class ExampleClass implements Parcelable {
abstract int intMember();
@NonNull
abstract String stringMember();
@NonNull
abstract List<NonParcelableClass> listMember();
}
@AutoValue
abstract class NonParcelableClass {
abstract int intMember();
@NonNull
abstract String stringMember();
}
In this case we'll get exception only at runtime, which sucks. I'm not familiar with code generation, so I don't know if we can check generic type parameters or not, but if we can, I think preventing those type of bugs at compile time is super-duper-cool.
It's supposed to do this already... I'll adapt your code to a test case later this week. Also feel free to try and create a PR with a failing test case if you want to beat me to it.
Also got bitten by this last week.
Confirmed we're only checking raw types. Will PR a fix