# 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)

*** ** * ** ***


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

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/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/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#Builder()()` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder`. |
| `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#Builder(androidx.appsearch.app.AppSearchBatchResult<KeyType,ValueType>)(appSearchBatchResult: https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult<KeyType!, ValueType!>)` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder` from the given `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult<KeyType!, ValueType!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#build()()` Builds an `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult` object from the contents of this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType!, ValueType!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#setFailure(KeyType,int,java.lang.String)(key: KeyType, resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, errorMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Associates the `key` with the provided failure code and error message. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType!, ValueType!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#setResult(KeyType,androidx.appsearch.app.AppSearchResult<ValueType>)(key: KeyType, result: https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult<ValueType!>)` Associates the `key` with the provided `result`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType!, ValueType!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBatchResult.Builder#setSuccess(KeyType,ValueType)(key: KeyType, value: ValueType?)` 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)

```
Builder()
```

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

### Builder

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

```
@ExperimentalAppSearchApi
Builder(appSearchBatchResult: AppSearchBatchResult<KeyType!, ValueType!>)
```

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

## Public functions

### build

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

```
fun build(): AppSearchBatchResult<KeyType!, ValueType!>
```

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

### setFailure

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

```
fun setFailure(key: KeyType, resultCode: Int, errorMessage: String?): AppSearchBatchResult.Builder<KeyType!, ValueType!>
```

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 |
|---|---|
| `key: KeyType` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `errorMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | 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)

```
fun setResult(key: KeyType, result: AppSearchResult<ValueType!>): AppSearchBatchResult.Builder<KeyType!, ValueType!>
```

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

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

| Parameters |
|---|---|
| `key: KeyType` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `result: https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult<ValueType!>` | The result to associate with the key. |

### setSuccess

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

```
fun setSuccess(key: KeyType, value: ValueType?): AppSearchBatchResult.Builder<KeyType!, ValueType!>
```

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 |
|---|---|
| `key: KeyType` | The key to associate the result with; usually corresponds to some identifier from the input like an ID or name. |
| `value: ValueType?` | An optional value to associate with the successful result of the operation being performed. |