TypeProtoConverters


public final class TypeProtoConverters


Converters from Any proto messages to their unwrapped target types.

Summary

Public methods

static T
<T> anyToType(@NonNull Any any)

Performs an Any proto message to type T conversion.

static Parcelable
byteStringToParcelable(
    @NonNull ByteString byteString,
    @NonNull Class<Parcelable> parcelableClass
)

Performs a ByteString to Parcelable conversion.

static T

Performs a ByteString to type T conversion.

static ByteString

Performs Parcelable to ByteString conversion.

static Any
<T> typeToAny(@NonNull T type)

Performs a type T to Any proto message conversion.

static ByteString

Performs an object to ByteString conversion.

Public methods

anyToType

public static T <T> anyToType(@NonNull Any any)

Performs an Any proto message to type T conversion.

Parameters
@NonNull Any any

type to unwrap into its target type T representation

Returns
T

unwrapped target type T

byteStringToParcelable

public static Parcelable byteStringToParcelable(
    @NonNull ByteString byteString,
    @NonNull Class<Parcelable> parcelableClass
)

Performs a ByteString to Parcelable conversion.

Parameters
@NonNull ByteString byteString

the ByteString to convert to a Parcelable

@NonNull Class<Parcelable> parcelableClass

the class type to create

Returns
Parcelable

instance of Parcelable

byteStringToType

public static T <T> byteStringToType(@NonNull ByteString byteString)

Performs a ByteString to type T conversion.

Parameters
@NonNull ByteString byteString

the ByteString to convert into T

Returns
T

instance of type T

parcelableToByteString

public static ByteString parcelableToByteString(@NonNull Parcelable parcelable)

Performs Parcelable to ByteString conversion.

Parameters
@NonNull Parcelable parcelable

Parcelable to convert to a ByteString

Returns
ByteString

ByteString representation of the passed object

typeToAny

public static Any <T> typeToAny(@NonNull T type)

Performs a type T to Any proto message conversion.

Parameters
@NonNull T type

target type to wrap into its Any representation

Returns
Any

Any proto message which contains the wrapped proto representation of T

typeToByteString

public static ByteString typeToByteString(@NonNull Object object)

Performs an object to ByteString conversion.

Parameters
@NonNull Object object

object to convert to a ByteString

Returns
ByteString

ByteString representation of the passed object