-
Notifications
You must be signed in to change notification settings - Fork 29
AutoValue Usage
Bradley Campbell edited this page Nov 27, 2016
·
7 revisions
Important: all information in this on this page is only relevant to PaperParcel 1.x. For information on the latest version of PaperParcel, visit http://grandstaish.github.io/paperparcel/
Simply implement Parcelable
on your AutoValue class and PaperParcel's AutoValue extension will take care of the rest, e.g.:
@AutoValue
public abstract class Example implements Parcelable {
public abstract int test();
public static State create(int test) {
return new AutoValue_Example(test);
}
}
Now your AutoValue
class can be passed directly to a Bundle
or Intent
.
A simple example can be found in the autovalue-example module.
Any TypeAdapter
annotated with @DefaultAdapter
will be used automatically unless a more specifically scoped adapter is applied.
For class-scoped TypeAdapter
s, apply directly to the @AutoValue
class, e.g.:
@AutoValue
@TypeAdapters(DateTypeAdapter.class)
public abstract class Example implements Parcelable {
...
}
For variable-scoped TypeAdapter
s, apply directly to the abstract property method, e.g.:
@AutoValue
public abstract class Example implements Parcelable {
@TypeAdapters(DateTypeAdapter.class)
public abstract Date test();
...
}