# TypeProtoConverters

Artifact: [androidx.test.espresso:espresso-remote](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/remote/TypeProtoConverters.java+class:androidx.test.espresso.remote.TypeProtoConverters)

*** ** * ** ***


```
public final class TypeProtoConverters
```

<br />

*** ** * ** ***

Converters from `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto messages to their unwrapped target types.

## Summary

| ### Public methods |
|---|---|
| `static T` | `<T> https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#anyToType(com.google.protobuf.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html any)` Performs an `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto message to type T conversion. |
| `static https://developer.android.com/reference/android/os/Parcelable.html` | `https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#byteStringToParcelable(com.google.protobuf.ByteString,java.lang.Class<android.os.Parcelable>)( @https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html byteString, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/android/os/Parcelable.html> parcelableClass )` Performs a `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to `https://developer.android.com/reference/android/os/Parcelable.html` conversion. |
| `static T` | `<T> https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#byteStringToType(com.google.protobuf.ByteString)(@https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html byteString)` Performs a `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to type T conversion. |
| `static https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` | `https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#parcelableToByteString(android.os.Parcelable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Parcelable.html parcelable)` Performs `https://developer.android.com/reference/android/os/Parcelable.html` to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` conversion. |
| `static https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` | `<T> https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#typeToAny(T)(@https://developer.android.com/reference/androidx/annotation/NonNull T type)` Performs a type T to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto message conversion. |
| `static https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` | `https://developer.android.com/reference/androidx/test/espresso/remote/TypeProtoConverters#typeToByteString(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html object)` Performs an object to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` conversion. |

## Public methods

### anyToType

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

Performs an `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto message to type T conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html 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 `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to `https://developer.android.com/reference/android/os/Parcelable.html` conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html byteString` | the `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to convert to a `https://developer.android.com/reference/android/os/Parcelable.html` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<https://developer.android.com/reference/android/os/Parcelable.html> parcelableClass` | the class type to create |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Parcelable.html` | instance of `https://developer.android.com/reference/android/os/Parcelable.html` |

### byteStringToType

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

Performs a `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to type T conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html byteString` | the `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` to convert into T |

| Returns |
|---|---|
| `T` | instance of type T |

### parcelableToByteString

```
public static ByteString parcelableToByteString(@NonNull Parcelable parcelable)
```

Performs `https://developer.android.com/reference/android/os/Parcelable.html` to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Parcelable.html parcelable` | `https://developer.android.com/reference/android/os/Parcelable.html` to convert to a `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` |

| Returns |
|---|---|
| `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` | `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` representation of the passed object |

### typeToAny

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

Performs a type T to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto message conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T type` | target type to wrap into its `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` representation |

| Returns |
|---|---|
| `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` | `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Any.html` proto message which contains the wrapped proto representation of T |

### typeToByteString

```
public static ByteString typeToByteString(@NonNull Object object)
```

Performs an object to `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` conversion.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html object` | object to convert to a `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` |

| Returns |
|---|---|
| `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` | `https://protobuf.dev/reference/java/api-docs/com/google/protobuf/ByteString.html` representation of the passed object |