TypeProtoConverters

public final class TypeProtoConverters


Converters from Any proto messages to their unwrapped target types.

Summary

Public constructors

Public methods

static T
<T> anyToType(Any any)

Performs an Any proto message to type T conversion.

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

Performs a ByteString to Parcelable conversion.

static T
<T> byteStringToType(ByteString byteString)

Performs a ByteString to type T conversion.

static ByteString
parcelableToByteString(Parcelable parcelable)

Performs Parcelable to ByteString conversion.

static Any
<T> typeToAny(T type)

Performs a type T to Any proto message conversion.

static ByteString

Performs an object to ByteString conversion.

Public constructors

TypeProtoConverters

public TypeProtoConverters()

Public methods

anyToType

public static T <T> anyToType(Any any)

Performs an Any proto message to type T conversion.

Parameters
Any any

type to unwrap into its target type T representation

Returns
T

unwrapped target type T

byteStringToParcelable

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

Performs a ByteString to Parcelable conversion.

Parameters
ByteString byteString

the ByteString to convert to a Parcelable

Returns
Parcelable

instance of Parcelable

byteStringToType

public static T <T> byteStringToType(ByteString byteString)

Performs a ByteString to type T conversion.

Parameters
ByteString byteString

the ByteString to convert into T

Returns
T

instance of type T

parcelableToByteString

public static ByteString parcelableToByteString(Parcelable parcelable)

Performs Parcelable to ByteString conversion.

Parameters
Parcelable parcelable

Parcelable to convert to a ByteString

Returns
ByteString

ByteString representation of the passed object

typeToAny

public static Any <T> typeToAny(T type)

Performs a type T to Any proto message conversion.

Parameters
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(Object object)

Performs an object to ByteString conversion.

Parameters
Object object

object to convert to a ByteString

Returns
ByteString

ByteString representation of the passed object