Metadata implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(entries.length); for (Entry entry : entries) { dest.writeParcelable(entry, 0); } } Metadata(Entry... entries);  Metadata(List<? extends Entry> entries);   Metadata(Parcel in); int length(); Metadata.Entry get(int index); Metadata copyWithAppendedEntriesFrom(@Nullable Metadata other); Metadata copyWithAppendedEntries(Entry... entriesToAppend); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Parcelable.Creator<Metadata> CREATOR; }
@Test public void testParcelable() { Metadata metadataToParcel = new Metadata( new BinaryFrame("id1", new byte[] {1}), new BinaryFrame("id2", new byte[] {2})); Parcel parcel = Parcel.obtain(); metadataToParcel.writeToParcel(parcel, 0); parcel.setDataPosition(0); Metadata metadataFromParcel = Metadata.CREATOR.createFromParcel(parcel); assertThat(metadataFromParcel).isEqualTo(metadataToParcel); parcel.recycle(); }