AppSearchBatchResult.Builder


public static final class AppSearchBatchResult.Builder
extends Object

java.lang.Object
   ↳ android.app.appsearch.AppSearchBatchResult.Builder


Builder for AppSearchBatchResult objects.

Summary

Public constructors

Builder()

Creates a new Builder.

Builder(AppSearchBatchResult appSearchBatchResult)

Creates a new Builder from the given AppSearchBatchResult.

Public methods

AppSearchBatchResult build()

Builds an AppSearchBatchResult object from the contents of this Builder.

Builder setFailure(KeyType key, int resultCode, String errorMessage)

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

Builder setResult(KeyType key, AppSearchResult result)

Associates the key with the provided result.

Builder setSuccess(KeyType key, ValueType value)

Associates the key with the provided successful return value.

Inherited methods

Public constructors

Builder

Added in API level 31
Also in T Extensions 17
public Builder ()

Creates a new Builder.

Builder

Added in API level 36
Also in T Extensions 17
public Builder (AppSearchBatchResult appSearchBatchResult)

Creates a new Builder from the given AppSearchBatchResult.

Parameters
appSearchBatchResult AppSearchBatchResult: This value cannot be null.

Public methods

build

Added in API level 31
public AppSearchBatchResult build ()

Builds an AppSearchBatchResult object from the contents of this Builder.

Returns
AppSearchBatchResult This value cannot be null.

setFailure

Added in API level 31
public Builder setFailure (KeyType key, 
                int resultCode, 
                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
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 AppSearchResult.getResultCode(). Value is AppSearchResult.RESULT_OK, AppSearchResult.RESULT_UNKNOWN_ERROR, AppSearchResult.RESULT_INTERNAL_ERROR, AppSearchResult.RESULT_INVALID_ARGUMENT, AppSearchResult.RESULT_IO_ERROR, AppSearchResult.RESULT_OUT_OF_SPACE, AppSearchResult.RESULT_NOT_FOUND, AppSearchResult.RESULT_INVALID_SCHEMA, AppSearchResult.RESULT_SECURITY_ERROR, AppSearchResult.RESULT_DENIED, AppSearchResult.RESULT_RATE_LIMITED, or AppSearchResult.RESULT_ALREADY_EXISTS
errorMessage String: An optional string describing the reason or nature of the failure. This value may be null.
Returns
Builder This value cannot be null.

setResult

Added in API level 31
public Builder setResult (KeyType key, 
                AppSearchResult result)

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: The result to associate with the key. This value cannot be null.
Returns
Builder This value cannot be null.

setSuccess

Added in API level 31
public Builder setSuccess (KeyType key, 
                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
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.
Returns
Builder This value cannot be null.