/* * Copyright 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.appsearch; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.appsearch.annotation.CanIgnoreReturnValue; import android.util.ArrayMap; import java.util.Collections; import java.util.Map; import java.util.Objects; /** * Provides results for AppSearch batch operations which encompass multiple documents. * *
Individual results of a batch operation are separated into two maps: one for successes and one * for failures. For successes, {@link #getSuccesses()} will return a map of keys to instances of * the value type. For failures, {@link #getFailures()} will return a map of keys to {@link * AppSearchResult} objects. * *
Alternatively, {@link #getAll()} returns a map of keys to {@link AppSearchResult} objects for
* both successes and failures.
*
* @param Example: {@link AppSearchSession#getByDocumentId} returns an {@link AppSearchBatchResult}.
* Each key (the document ID, of {@code String} type) will map to a {@link GenericDocument}
* object.
*
* The values of the {@link Map} will not be {@code null}.
*/
@NonNull
public Map The values of the {@link Map} will not be {@code null}.
*/
@NonNull
public Map The values of the {@link Map} will not be {@code null}.
*/
@NonNull
public Map Any previous mapping for a key, whether success or failure, is deleted.
*
* This is a convenience function which is equivalent to {@code setResult(key,
* AppSearchResult.newSuccessfulResult(value))}.
*
* @param key The key to associate the result with; usually corresponds to some identifier
* from the input like an ID or name.
* @param value An optional value to associate with the successful result of the operation
* being performed.
*/
@CanIgnoreReturnValue
@SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses
@NonNull
public Builder Any previous mapping for a key, whether success or failure, is deleted.
*
* This is a convenience function which is equivalent to {@code setResult(key,
* AppSearchResult.newFailedResult(resultCode, errorMessage))}.
*
* @param key The key to associate the result with; usually corresponds to some identifier
* from the input like an ID or name.
* @param resultCode One of the constants documented in {@link
* AppSearchResult#getResultCode}.
* @param errorMessage An optional string describing the reason or nature of the failure.
*/
@CanIgnoreReturnValue
@SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures
@NonNull
public Builder Any previous mapping for a key, whether success or failure, is deleted.
*
* @param key The key to associate the result with; usually corresponds to some identifier
* from the input like an ID or name.
* @param result The result to associate with the key.
*/
@CanIgnoreReturnValue
@SuppressWarnings("MissingGetterMatchingBuilder") // See getAll
@NonNull
public Builder