# AppSearchBatchResult.Builder

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/AppSearchBatchResult.java+class:androidx.appsearch.app.AppSearchBatchResult.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
public final class AppSearchBatchResult.Builder<KeyType, ValueType>
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` objects.

| Parameters |
|---|---|
| `<KeyType>` | The type of the keys for which the results will be reported. |
| `<ValueType>` | The type of the result objects for successful results. |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#Builder()()` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder`. |
| `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#Builder(androidx.appsearch.app.AppSearchBatchResult<KeyType,ValueType>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult<KeyType, ValueType> appSearchBatchResult )` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder` from the given `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult<KeyType, ValueType>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#build()()` Builds an `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` object from the contents of this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType, ValueType>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#setFailure(KeyType,int,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key, int resultCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html errorMessage )` Associates the `key` with the provided failure code and error message. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType, ValueType>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#setResult(KeyType,androidx.appsearch.app.AppSearchResult<ValueType>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType> result)` Associates the `key` with the provided `result`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType, ValueType>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder#setSuccess(KeyType,ValueType)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html ValueType value)` Associates the `key` with the provided successful return value. |

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public Builder()
```

Creates a new `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder`.

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
public Builder(
    @NonNull AppSearchBatchResult<KeyType, ValueType> appSearchBatchResult
)
```

Creates a new `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder` from the given `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult`.

## Public methods

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull AppSearchBatchResult<KeyType, ValueType> build()
```

Builds an `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` object from the contents of this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder`.

### setFailure

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull AppSearchBatchResult.Builder<KeyType, ValueType> setFailure(
    @NonNull KeyType key,
    int resultCode,
    @Nullable String errorMessage
)
```

Associates the `key` with the provided failure code and error message.

Any previous mapping for a key, whether success or failure, is deleted.

This is a convenience function which is equivalent to `setResult(key, AppSearchResult.newFailedResult(resultCode, errorMessage))`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `int resultCode` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html errorMessage` | An optional string describing the reason or nature of the failure. |

### setResult

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull AppSearchBatchResult.Builder<KeyType, ValueType> setResult(@NonNull KeyType key, @NonNull AppSearchResult<ValueType> result)
```

Associates the `key` with the provided `result`.

Any previous mapping for a key, whether success or failure, is deleted.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType> result` | The result to associate with the key. |

### setSuccess

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull AppSearchBatchResult.Builder<KeyType, ValueType> setSuccess(@NonNull KeyType key, @Nullable ValueType value)
```

Associates the `key` with the provided successful return value.

Any previous mapping for a key, whether success or failure, is deleted.

This is a convenience function which is equivalent to `setResult(key, AppSearchResult.newSuccessfulResult(value))`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html KeyType key` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html ValueType value` | An optional value to associate with the successful result of the operation being performed. |