AppSearchBatchResult.Builder

public final class AppSearchBatchResult.Builder<KeyType, ValueType>


Builder for 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

Public methods

@NonNull AppSearchBatchResult<KeyType, ValueType>

Builds an AppSearchBatchResult object from the contents of this Builder.

@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.

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

Associates the key with the provided result.

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

Associates the key with the provided successful return value.

Public constructors

Builder

Added in 1.1.0-alpha04
public Builder()

Public methods

build

Added in 1.1.0-alpha04
public @NonNull AppSearchBatchResult<KeyType, ValueType> build()

Builds an AppSearchBatchResult object from the contents of this Builder.

setFailure

Added in 1.1.0-alpha04
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
@NonNull 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 getResultCode.

@Nullable String errorMessage

An optional string describing the reason or nature of the failure.

setResult

Added in 1.1.0-alpha04
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
@NonNull KeyType key

The key to associate the result with; usually corresponds to some identifier from the input like an ID or name.

@NonNull AppSearchResult<ValueType> result

The result to associate with the key.

setSuccess

Added in 1.1.0-alpha04
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
@NonNull KeyType key

The key to associate the result with; usually corresponds to some identifier from the input like an ID or name.

@Nullable ValueType value

An optional value to associate with the successful result of the operation being performed.