# ResultTransform


```
public abstract class ResultTransform<R extends Result, S extends Result>
```

<br />

*** ** * ** ***

Transforms a `https://developers.google.com/android/reference/com/google/android/gms/common/api/Result` by making a subsequent API call.

| See also |
|---|---|
| `https://developers.google.com/android/reference/com/google/android/gms/common/api/PendingResult#then(com.google.android.gms.common.api.ResultTransform<? super R,? extends S>)` |   |

## Summary

| ### Public constructors |
|---|
| `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#ResultTransform()()` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/PendingResult<S>` | `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#createFailedResult(com.google.android.gms.common.api.Status)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/Status status)` Creates a failed result with the given `https://developers.google.com/android/reference/com/google/android/gms/common/api/Status`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/Status` | `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#onFailure(com.google.android.gms.common.api.Status)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/Status status)` Called when the PendingResult to be transformed returns a failure. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/android/reference/com/google/android/gms/common/api/PendingResult<S>` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread.html https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#onSuccess(R)(@https://developer.android.com/reference/androidx/annotation/NonNull.html R result)` Transforms the result of a successful API call. |

## Public constructors

### ResultTransform

```
public ResultTransform()
```

## Public methods

### createFailedResult

```
public final @NonNull PendingResult<S> createFailedResult(@NonNull Status status)
```

Creates a failed result with the given `https://developers.google.com/android/reference/com/google/android/gms/common/api/Status`. In the event of an error during `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#onSuccess(R)`, call this method and return the failed result.

Note: the `https://developers.google.com/android/reference/com/google/android/gms/common/api/PendingResult` generated by this method must be returned directly from `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#onSuccess(R)`. It is an error to call any methods on this PendingResult.

### onFailure

```
public @NonNull Status onFailure(@NonNull Status status)
```

Called when the PendingResult to be transformed returns a failure. Default implementation simply propagates the failure, but subclasses may override for custom failure handling. This method is called on the main thread, unless overridden by `https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient.Builder#setHandler(android.os.Handler)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/Status status` | The status of the failure. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/common/api/Status` | The status of the result of the transformation. Must not be success or null. |

### onSuccess

```
@WorkerThread
public abstract @Nullable PendingResult<S> onSuccess(@NonNull R result)
```

Transforms the result of a successful API call. This method is called on a background thread and should not access UI elements.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html R result` | The successful result to be transformed. Never null. If this result is `https://developers.google.com/android/reference/com/google/android/gms/common/api/Releasable` it will be automatically released after this transform is applied; it is not necessary to release the result inside onSuccess. It is an error to set callbacks on this result. Any callbacks set on this result will be overridden and will not be called. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developers.google.com/android/reference/com/google/android/gms/common/api/PendingResult<S>` | The result of the transformation. Normally the result of another API call. To shortcut execution and directly yield a failure, return either: - `null`, which is translated into a `https://developers.google.com/android/reference/com/google/android/gms/common/api/Status` with code `https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes#ERROR()`; or - a specific failure created using `https://developers.google.com/android/reference/com/google/android/gms/common/api/ResultTransform#createFailedResult(com.google.android.gms.common.api.Status)`. |