{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Parcelables

public final class Parcelables


Testing utilities for Parcelables.

Summary

Public methods

static @NonNull T
<T extends Parcelable> forceParcel(
    @NonNull T parcelable,
    @NonNull Creator<T> creator
)

Parcelables are lazily marshalled, meaning that in typical testing, no marshalling would occur and would therefore go untested.

Public methods

forceParcel

@NonNull
public static T <T extends Parcelable> forceParcel(
    @NonNull T parcelable,
    @NonNull Creator<T> creator
)

Parcelables are lazily marshalled, meaning that in typical testing, no marshalling would occur and would therefore go untested. This forces marshalling to happen for a Parcelable.

This utility will marshall the provided Parcelable, and attempt to recreate it with the given CREATOR. It is up to the caller to validate the two instances are equivalent.

Parameters
@NonNull T parcelable

the parcelable to marshall.

@NonNull Creator<T> creator

the CREATOR field for that parcelable.

Returns
T

a new instance of the parcelable that has been unmarshalled.