Parcelable listParcelable = Parcels.wrap(new ArrayList<Example>());
Parcelable mapParcelable = Parcels.wrap(new HashMap<String, Example>());
@Target(value=TYPE) @Retention(value=RUNTIME) public @interface Parcel
Identifies a class to be wrapped by a Parcelable wrapper.
This wrapper will serialize an instance of the current class to and from a Parcelable representation based on the serialization technique value if no ParcelConverter value is specified.
If a ParcelConverter is specified it will be used instead.
Only a select number of types may be used as attributes of a @Parcel class.
The following list includes the mapped types:
byte
double
float
int
long
char
boolean
String
IBinder
Bundle
SparseArray of any of the mapped types*
SparseBooleanArray
List, ArrayList and LinkedList of any of the mapped types*
Map, HashMap, LinkedHashMap, SortedMap, and TreeMap of any of the mapped types*
Set, HashSet, SortedSet, TreeSet, LinkedHashSet of any of the mapped types*
Parcelable
Serializable
Array of any of the mapped types
Any other class annotated with @Parcel
Parcel will error if the generic parameter is not mapped.
Parceler also supports any of the above types directly.
This is especially useful when dealing with collections of classes annotated with @Parcel:
Parcelable listParcelable = Parcels.wrap(new ArrayList<Example>());
Parcelable mapParcelable = Parcels.wrap(new HashMap<String, Example>());
Properties that should not be serialized can be annotated with the @Transient annotation on either the getter or setter.
Parceler will ignore @Transient annotated properties during Parcelable serialization.
| Modifier and Type | Optional Element and Description |
|---|---|
Class[] |
analyze
Identifies the types to include in analysis.
|
Class<? extends TypeRangeParcelConverter> |
converter
ParcelConverter to use when serializing this class. |
int |
describeContents
Value to be returned by the generated
describeContents() method. |
Class[] |
implementations
The concrete implementations that should be mapped to this class for use with the Parcels utility class.
|
Parcel.Serialization |
value
Specifies the technique for which Parceler will serialize.
|
public abstract Parcel.Serialization value
Specifies the technique for which Parceler will serialize.
public abstract Class[] implementations
The concrete implementations that should be mapped to this class for use with the Parcels utility class.
public abstract Class<? extends TypeRangeParcelConverter> converter
ParcelConverter to use when serializing this class.
Parceler will attempt to generate serialization specifics if this converter is not specified.
public abstract int describeContents
Value to be returned by the generated describeContents() method.
Copyright © 2017. All Rights Reserved.