Loading apex/appsearch/framework/java/external/android/app/appsearch/AppSearchBatchResult.java +31 −10 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.util.ArrayMap; import java.util.Collections; import java.util.Map; import java.util.Objects; Loading Loading @@ -48,9 +49,9 @@ public final class AppSearchBatchResult<KeyType, ValueType> { @NonNull Map<KeyType, ValueType> successes, @NonNull Map<KeyType, AppSearchResult<ValueType>> failures, @NonNull Map<KeyType, AppSearchResult<ValueType>> all) { mSuccesses = successes; mFailures = failures; mAll = all; mSuccesses = Objects.requireNonNull(successes); mFailures = Objects.requireNonNull(failures); mAll = Objects.requireNonNull(all); } /** Returns {@code true} if this {@link AppSearchBatchResult} has no failures. */ Loading @@ -70,7 +71,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, ValueType> getSuccesses() { return mSuccesses; return Collections.unmodifiableMap(mSuccesses); } /** Loading @@ -81,7 +82,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, AppSearchResult<ValueType>> getFailures() { return mFailures; return Collections.unmodifiableMap(mFailures); } /** Loading @@ -92,7 +93,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, AppSearchResult<ValueType>> getAll() { return mAll; return Collections.unmodifiableMap(mAll); } /** Loading Loading @@ -128,20 +129,37 @@ public final class AppSearchBatchResult<KeyType, ValueType> { * Associates the {@code key} with the provided successful return value. * * <p>Any previous mapping for a key, whether success or failure, is deleted. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses @NonNull public Builder<KeyType, ValueType> setSuccess( @NonNull KeyType key, @Nullable ValueType result) { @NonNull KeyType key, @Nullable ValueType value) { Objects.requireNonNull(key); resetIfBuilt(); return setResult(key, AppSearchResult.newSuccessfulResult(result)); return setResult(key, AppSearchResult.newSuccessfulResult(value)); } /** * Associates the {@code key} with the provided failure code and error message. * * <p>Any previous mapping for a key, whether success or failure, is deleted. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures @NonNull Loading @@ -158,6 +176,10 @@ public final class AppSearchBatchResult<KeyType, ValueType> { * Associates the {@code key} with the provided {@code result}. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll @NonNull Loading @@ -183,8 +205,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { @NonNull public AppSearchBatchResult<KeyType, ValueType> build() { mBuilt = true; return new AppSearchBatchResult<>( new ArrayMap<>(mSuccesses), new ArrayMap<>(mFailures), new ArrayMap<>(mAll)); return new AppSearchBatchResult<>(mSuccesses, mFailures, mAll); } private void resetIfBuilt() { Loading apex/appsearch/framework/java/external/android/app/appsearch/AppSearchResult.java +12 −2 Original line number Diff line number Diff line Loading @@ -175,14 +175,24 @@ public final class AppSearchResult<ValueType> { return "[FAILURE(" + mResultCode + ")]: " + mErrorMessage; } /** Creates a new successful {@link AppSearchResult}. */ /** * Creates a new successful {@link AppSearchResult}. * * @param value An optional value to associate with the successful result of the operation being * performed. */ @NonNull public static <ValueType> AppSearchResult<ValueType> newSuccessfulResult( @Nullable ValueType value) { return new AppSearchResult<>(RESULT_OK, value, /*errorMessage=*/ null); } /** Creates a new failed {@link AppSearchResult}. */ /** * Creates a new failed {@link AppSearchResult}. * * @param resultCode One of the constants documented in {@link AppSearchResult#getResultCode}. * @param errorMessage An optional string describing the reason or nature of the failure. */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( @ResultCode int resultCode, @Nullable String errorMessage) { Loading apex/appsearch/framework/java/external/android/app/appsearch/GetByDocumentIdRequest.java +1 −2 Original line number Diff line number Diff line Loading @@ -164,8 +164,7 @@ public final class GetByDocumentIdRequest { @NonNull public GetByDocumentIdRequest build() { mBuilt = true; return new GetByDocumentIdRequest( mNamespace, new ArraySet<>(mIds), new ArrayMap<>(mProjectionTypePropertyPaths)); return new GetByDocumentIdRequest(mNamespace, mIds, mProjectionTypePropertyPaths); } private void resetIfBuilt() { Loading apex/appsearch/framework/java/external/android/app/appsearch/ReportSystemUsageRequest.java +14 −3 Original line number Diff line number Diff line Loading @@ -93,14 +93,25 @@ public final class ReportSystemUsageRequest { private final String mDocumentId; private Long mUsageTimestampMillis; /** Creates a {@link ReportSystemUsageRequest.Builder} instance. */ /** * Creates a {@link ReportSystemUsageRequest.Builder} instance. * * @param packageName The package name of the app which owns the document that was used * (e.g. from {@link SearchResult#getPackageName}). * @param databaseName The database in which the document that was used resides (e.g. from * {@link SearchResult#getDatabaseName}). * @param namespace The namespace of the document that was used (e.g. from {@link * GenericDocument#getNamespace}. * @param documentId The ID of document that was used (e.g. from {@link * GenericDocument#getId}. */ public Builder( @NonNull String packageName, @NonNull String database, @NonNull String databaseName, @NonNull String namespace, @NonNull String documentId) { mPackageName = Objects.requireNonNull(packageName); mDatabase = Objects.requireNonNull(database); mDatabase = Objects.requireNonNull(databaseName); mNamespace = Objects.requireNonNull(namespace); mDocumentId = Objects.requireNonNull(documentId); } Loading apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java +8 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,14 @@ public final class ReportUsageRequest { private String mDocumentId; private Long mUsageTimestampMillis; /** Creates a {@link ReportUsageRequest.Builder} instance. */ /** * Creates a new {@link ReportUsageRequest.Builder} instance. * * @param namespace The namespace of the document that was used (e.g. from {@link * GenericDocument#getNamespace}. * @param documentId The ID of document that was used (e.g. from {@link * GenericDocument#getId}. */ public Builder(@NonNull String namespace, @NonNull String documentId) { mNamespace = Objects.requireNonNull(namespace); mDocumentId = Objects.requireNonNull(documentId); Loading Loading
apex/appsearch/framework/java/external/android/app/appsearch/AppSearchBatchResult.java +31 −10 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.util.ArrayMap; import java.util.Collections; import java.util.Map; import java.util.Objects; Loading Loading @@ -48,9 +49,9 @@ public final class AppSearchBatchResult<KeyType, ValueType> { @NonNull Map<KeyType, ValueType> successes, @NonNull Map<KeyType, AppSearchResult<ValueType>> failures, @NonNull Map<KeyType, AppSearchResult<ValueType>> all) { mSuccesses = successes; mFailures = failures; mAll = all; mSuccesses = Objects.requireNonNull(successes); mFailures = Objects.requireNonNull(failures); mAll = Objects.requireNonNull(all); } /** Returns {@code true} if this {@link AppSearchBatchResult} has no failures. */ Loading @@ -70,7 +71,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, ValueType> getSuccesses() { return mSuccesses; return Collections.unmodifiableMap(mSuccesses); } /** Loading @@ -81,7 +82,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, AppSearchResult<ValueType>> getFailures() { return mFailures; return Collections.unmodifiableMap(mFailures); } /** Loading @@ -92,7 +93,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { */ @NonNull public Map<KeyType, AppSearchResult<ValueType>> getAll() { return mAll; return Collections.unmodifiableMap(mAll); } /** Loading Loading @@ -128,20 +129,37 @@ public final class AppSearchBatchResult<KeyType, ValueType> { * Associates the {@code key} with the provided successful return value. * * <p>Any previous mapping for a key, whether success or failure, is deleted. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses @NonNull public Builder<KeyType, ValueType> setSuccess( @NonNull KeyType key, @Nullable ValueType result) { @NonNull KeyType key, @Nullable ValueType value) { Objects.requireNonNull(key); resetIfBuilt(); return setResult(key, AppSearchResult.newSuccessfulResult(result)); return setResult(key, AppSearchResult.newSuccessfulResult(value)); } /** * Associates the {@code key} with the provided failure code and error message. * * <p>Any previous mapping for a key, whether success or failure, is deleted. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures @NonNull Loading @@ -158,6 +176,10 @@ public final class AppSearchBatchResult<KeyType, ValueType> { * Associates the {@code key} with the provided {@code result}. * * <p>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. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll @NonNull Loading @@ -183,8 +205,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> { @NonNull public AppSearchBatchResult<KeyType, ValueType> build() { mBuilt = true; return new AppSearchBatchResult<>( new ArrayMap<>(mSuccesses), new ArrayMap<>(mFailures), new ArrayMap<>(mAll)); return new AppSearchBatchResult<>(mSuccesses, mFailures, mAll); } private void resetIfBuilt() { Loading
apex/appsearch/framework/java/external/android/app/appsearch/AppSearchResult.java +12 −2 Original line number Diff line number Diff line Loading @@ -175,14 +175,24 @@ public final class AppSearchResult<ValueType> { return "[FAILURE(" + mResultCode + ")]: " + mErrorMessage; } /** Creates a new successful {@link AppSearchResult}. */ /** * Creates a new successful {@link AppSearchResult}. * * @param value An optional value to associate with the successful result of the operation being * performed. */ @NonNull public static <ValueType> AppSearchResult<ValueType> newSuccessfulResult( @Nullable ValueType value) { return new AppSearchResult<>(RESULT_OK, value, /*errorMessage=*/ null); } /** Creates a new failed {@link AppSearchResult}. */ /** * Creates a new failed {@link AppSearchResult}. * * @param resultCode One of the constants documented in {@link AppSearchResult#getResultCode}. * @param errorMessage An optional string describing the reason or nature of the failure. */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( @ResultCode int resultCode, @Nullable String errorMessage) { Loading
apex/appsearch/framework/java/external/android/app/appsearch/GetByDocumentIdRequest.java +1 −2 Original line number Diff line number Diff line Loading @@ -164,8 +164,7 @@ public final class GetByDocumentIdRequest { @NonNull public GetByDocumentIdRequest build() { mBuilt = true; return new GetByDocumentIdRequest( mNamespace, new ArraySet<>(mIds), new ArrayMap<>(mProjectionTypePropertyPaths)); return new GetByDocumentIdRequest(mNamespace, mIds, mProjectionTypePropertyPaths); } private void resetIfBuilt() { Loading
apex/appsearch/framework/java/external/android/app/appsearch/ReportSystemUsageRequest.java +14 −3 Original line number Diff line number Diff line Loading @@ -93,14 +93,25 @@ public final class ReportSystemUsageRequest { private final String mDocumentId; private Long mUsageTimestampMillis; /** Creates a {@link ReportSystemUsageRequest.Builder} instance. */ /** * Creates a {@link ReportSystemUsageRequest.Builder} instance. * * @param packageName The package name of the app which owns the document that was used * (e.g. from {@link SearchResult#getPackageName}). * @param databaseName The database in which the document that was used resides (e.g. from * {@link SearchResult#getDatabaseName}). * @param namespace The namespace of the document that was used (e.g. from {@link * GenericDocument#getNamespace}. * @param documentId The ID of document that was used (e.g. from {@link * GenericDocument#getId}. */ public Builder( @NonNull String packageName, @NonNull String database, @NonNull String databaseName, @NonNull String namespace, @NonNull String documentId) { mPackageName = Objects.requireNonNull(packageName); mDatabase = Objects.requireNonNull(database); mDatabase = Objects.requireNonNull(databaseName); mNamespace = Objects.requireNonNull(namespace); mDocumentId = Objects.requireNonNull(documentId); } Loading
apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java +8 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,14 @@ public final class ReportUsageRequest { private String mDocumentId; private Long mUsageTimestampMillis; /** Creates a {@link ReportUsageRequest.Builder} instance. */ /** * Creates a new {@link ReportUsageRequest.Builder} instance. * * @param namespace The namespace of the document that was used (e.g. from {@link * GenericDocument#getNamespace}. * @param documentId The ID of document that was used (e.g. from {@link * GenericDocument#getId}. */ public Builder(@NonNull String namespace, @NonNull String documentId) { mNamespace = Objects.requireNonNull(namespace); mDocumentId = Objects.requireNonNull(documentId); Loading