# AppSearchBatchResult.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/appsearch/AppSearchBatchResult.Builder "View this page in Java")  

```
class Builder<KeyType : Any!, ValueType : Any!>
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                           ||
| ↳ | [android.app.appsearch.AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#) |

Builder for[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)objects.

## Summary

|                                                                                                                                                                                                                                                                                         Public constructors                                                                                                                                                                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#Builder())`()` Creates a new[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#).                                                                                                                                                                                                                                                                                                                                           |
| [Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#Builder(android.app.appsearch.AppSearchBatchResult))`(`appSearchBatchResult:` `[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)<KeyType,` `ValueType>`)` Creates a new[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)from the given[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult). |

|                                                                                                                                                                                                                                                                                                                              Public methods                                                                                                                                                                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)\<KeyType,ValueType\>                  | [build](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#build())`()` Builds an[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)object from the contents of this[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#).                                                                                                                 |
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)\<KeyType,ValueType\> | [setFailure](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#setFailure(android.app.appsearch.AppSearchBatchResult.Builder.KeyType,%20kotlin.Int,%20kotlin.String))`(`key:` `KeyType`, `resultCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `errorMessage:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Associates the`key`with the provided failure code and error message. |
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)\<KeyType,ValueType\> | [setResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#setResult(android.app.appsearch.AppSearchBatchResult.Builder.KeyType,%20android.app.appsearch.AppSearchResult))`(`key:` `KeyType`, `result:` `[AppSearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult)<ValueType>`)` Associates the`key`with the provided`result`.                                                                                 |
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)\<KeyType,ValueType\> | [setSuccess](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#setSuccess(android.app.appsearch.AppSearchBatchResult.Builder.KeyType,%20android.app.appsearch.AppSearchBatchResult.Builder.ValueType))`(`key:` `KeyType`, `value:` `ValueType?`)` Associates the`key`with the provided successful return value.                                                                                                                                                 |

## Public constructors

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 17](https://developer.android.com/sdkExtensions)  

```
Builder()
```

Creates a new[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#).  

### Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 17](https://developer.android.com/sdkExtensions)  

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

Creates a new[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)from the given[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult).

|                                                                                         Parameters                                                                                         ||
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `appSearchBatchResult` | [AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)\<KeyType,ValueType\>:This value cannot be`null`. |

## Public methods

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Builds an[AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)object from the contents of this[Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#).

|                                                                                Return                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AppSearchBatchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult)<KeyType,` `ValueType> | This value cannot be`null`. |

### setFailure

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `resultCode`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):One of the constants documented in[android.app.appsearch.AppSearchResult#getResultCode](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#getResultCode()). Value is[android.app.appsearch.AppSearchResult#RESULT_OK](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_OK:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_UNKNOWN_ERROR](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_UNKNOWN_ERROR:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_INTERNAL_ERROR](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_INTERNAL_ERROR:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_INVALID_ARGUMENT](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_INVALID_ARGUMENT:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_IO_ERROR](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_IO_ERROR:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_OUT_OF_SPACE](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_OUT_OF_SPACE:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_NOT_FOUND](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_NOT_FOUND:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_INVALID_SCHEMA](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_INVALID_SCHEMA:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_SECURITY_ERROR](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_SECURITY_ERROR:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_DENIED](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_DENIED:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_RATE_LIMITED](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_RATE_LIMITED:kotlin.Int),[android.app.appsearch.AppSearchResult#RESULT_ALREADY_EXISTS](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_ALREADY_EXISTS:kotlin.Int), android.app.appsearch.AppSearchResult.RESULT_ABORTED, or android.app.appsearch.AppSearchResult.RESULT_UNAVAILABLE |
| `errorMessage` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:An optional string describing the reason or nature of the failure. This value may be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

|                                                                                        Return                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)<KeyType,` `ValueType> | This value cannot be`null`. |

### setResult

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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. This value cannot be`null`.                                    |
| `result` | [AppSearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult)\<ValueType\>:The result to associate with the key. This value cannot be`null`. |

|                                                                                        Return                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)<KeyType,` `ValueType> | This value cannot be`null`. |

### setSuccess

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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. This value cannot be`null`. |
| `value` | ValueType?:An optional value to associate with the successful result of the operation being performed. This value may be`null`.                     |

|                                                                                        Return                                                                                         ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AppSearchBatchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBatchResult.Builder#)<KeyType,` `ValueType> | This value cannot be`null`. |