Added in API level 31

Builder


class Builder<KeyType : Any!, ValueType : Any!>
kotlin.Any
   ↳ android.app.appsearch.AppSearchBatchResult.Builder

Builder for AppSearchBatchResult objects.

Summary

Public constructors

Public methods
AppSearchBatchResult<KeyType, ValueType>

Builds an AppSearchBatchResult object from the contents of this Builder.

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

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

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

Associates the key with the provided result.

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

Associates the key with the provided successful return value.

Public constructors

Builder

Added in API level 31
Builder()

Public methods

build

Added in API level 31
fun build(): AppSearchBatchResult<KeyType, ValueType>

Builds an AppSearchBatchResult object from the contents of this Builder.

Return
AppSearchBatchResult<KeyType, ValueType> This value cannot be null.

setFailure

Added in API level 31
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: One of the constants documented in android.app.appsearch.AppSearchResult#getResultCode. Value is android.app.appsearch.AppSearchResult#RESULT_OK, android.app.appsearch.AppSearchResult#RESULT_UNKNOWN_ERROR, android.app.appsearch.AppSearchResult#RESULT_INTERNAL_ERROR, android.app.appsearch.AppSearchResult#RESULT_INVALID_ARGUMENT, android.app.appsearch.AppSearchResult#RESULT_IO_ERROR, android.app.appsearch.AppSearchResult#RESULT_OUT_OF_SPACE, android.app.appsearch.AppSearchResult#RESULT_NOT_FOUND, android.app.appsearch.AppSearchResult#RESULT_INVALID_SCHEMA, android.app.appsearch.AppSearchResult#RESULT_SECURITY_ERROR, android.app.appsearch.AppSearchResult.RESULT_DENIED, android.app.appsearch.AppSearchResult.RESULT_RATE_LIMITED, or android.app.appsearch.AppSearchResult.RESULT_TIMED_OUT
errorMessage String?: An optional string describing the reason or nature of the failure. This value may be null.
Return
AppSearchBatchResult.Builder<KeyType, ValueType> This value cannot be null.

setResult

Added in API level 31
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<ValueType>: The result to associate with the key. This value cannot be null.
Return
AppSearchBatchResult.Builder<KeyType, ValueType> This value cannot be null.

setSuccess

Added in API level 31
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<KeyType, ValueType> This value cannot be null.