Loading apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java +13 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import java.util.Objects; * @param <ValueType> The type of result object for successful calls. */ public final class AppSearchResult<ValueType> implements Parcelable { private static final String TAG = "AppSearchResult"; /** * Result codes from {@link AppSearchSession} methods. * @hide Loading Loading @@ -246,14 +248,22 @@ public final class AppSearchResult<ValueType> implements Parcelable { @NonNull public static <ValueType> AppSearchResult<ValueType> throwableToFailedResult( @NonNull Throwable t) { Log.d("AppSearchResult", "Converting throwable to failed result.", t); // Log for traceability. NOT_FOUND is logged at VERBOSE because this error can occur during // the regular operation of the system (b/183550974). Everything else is logged at DEBUG. if (t instanceof AppSearchException && ((AppSearchException) t).getResultCode() == RESULT_NOT_FOUND) { Log.v(TAG, "Converting throwable to failed result: " + t); } else { Log.d(TAG, "Converting throwable to failed result.", t); } if (t instanceof AppSearchException) { return ((AppSearchException) t).toAppSearchResult(); } String exceptionClass = t.getClass().getSimpleName(); @AppSearchResult.ResultCode int resultCode; if (t instanceof IllegalStateException) { if (t instanceof IllegalStateException || t instanceof NullPointerException) { resultCode = AppSearchResult.RESULT_INTERNAL_ERROR; } else if (t instanceof IllegalArgumentException) { resultCode = AppSearchResult.RESULT_INVALID_ARGUMENT; Loading @@ -262,6 +272,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { } else { resultCode = AppSearchResult.RESULT_UNKNOWN_ERROR; } return AppSearchResult.newFailedResult(resultCode, t.getMessage()); return AppSearchResult.newFailedResult(resultCode, exceptionClass + ": " + t.getMessage()); } } apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java +6 −6 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ public final class AppSearchSchema { /** @hide */ public AppSearchSchema(@NonNull Bundle bundle) { Preconditions.checkNotNull(bundle); Objects.requireNonNull(bundle); mBundle = bundle; } Loading Loading @@ -125,7 +125,7 @@ public final class AppSearchSchema { /** Creates a new {@link AppSearchSchema.Builder}. */ public Builder(@NonNull String schemaType) { Preconditions.checkNotNull(schemaType); Objects.requireNonNull(schemaType); mSchemaType = schemaType; } Loading @@ -133,7 +133,7 @@ public final class AppSearchSchema { @NonNull public AppSearchSchema.Builder addProperty(@NonNull PropertyConfig propertyConfig) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(propertyConfig); Objects.requireNonNull(propertyConfig); String name = propertyConfig.getName(); if (!mPropertyNames.add(name)) { throw new IllegalSchemaException("Property defined more than once: " + name); Loading Loading @@ -246,7 +246,7 @@ public final class AppSearchSchema { @Nullable private Integer mHashCode; PropertyConfig(@NonNull Bundle bundle) { mBundle = Preconditions.checkNotNull(bundle); mBundle = Objects.requireNonNull(bundle); } @Override Loading Loading @@ -712,7 +712,7 @@ public final class AppSearchSchema { /** Returns the logical schema-type of the contents of this document property. */ @NonNull public String getSchemaType() { return Preconditions.checkNotNull(mBundle.getString(SCHEMA_TYPE_FIELD)); return Objects.requireNonNull(mBundle.getString(SCHEMA_TYPE_FIELD)); } /** Loading Loading @@ -755,7 +755,7 @@ public final class AppSearchSchema { @NonNull public DocumentPropertyConfig.Builder setSchemaType(@NonNull String schemaType) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(schemaType); Objects.requireNonNull(schemaType); mBundle.putString(SCHEMA_TYPE_FIELD, schemaType); return this; } Loading apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java +37 −41 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Objects; import java.util.Set; /** Loading Loading @@ -101,11 +102,11 @@ public class GenericDocument { * @hide */ public GenericDocument(@NonNull Bundle bundle) { Preconditions.checkNotNull(bundle); Objects.requireNonNull(bundle); mBundle = bundle; mProperties = Preconditions.checkNotNull(bundle.getParcelable(PROPERTIES_FIELD)); mUri = Preconditions.checkNotNull(mBundle.getString(URI_FIELD)); mSchemaType = Preconditions.checkNotNull(mBundle.getString(SCHEMA_TYPE_FIELD)); mProperties = Objects.requireNonNull(bundle.getParcelable(PROPERTIES_FIELD)); mUri = Objects.requireNonNull(mBundle.getString(URI_FIELD)); mSchemaType = Objects.requireNonNull(mBundle.getString(SCHEMA_TYPE_FIELD)); mCreationTimestampMillis = mBundle.getLong(CREATION_TIMESTAMP_MILLIS_FIELD, System.currentTimeMillis()); } Loading Loading @@ -199,7 +200,7 @@ public class GenericDocument { */ @Nullable public Object getProperty(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); Object property = mProperties.get(key); if (property instanceof ArrayList) { return getPropertyBytesArray(key); Loading @@ -218,7 +219,7 @@ public class GenericDocument { */ @Nullable public String getPropertyString(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); String[] propertyArray = getPropertyStringArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading @@ -235,7 +236,7 @@ public class GenericDocument { * there is no such key or the value is of a different type. */ public long getPropertyLong(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); long[] propertyArray = getPropertyLongArray(key); if (propertyArray == null || propertyArray.length == 0) { return 0; Loading @@ -252,7 +253,7 @@ public class GenericDocument { * if there is no such key or the value is of a different type. */ public double getPropertyDouble(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); double[] propertyArray = getPropertyDoubleArray(key); if (propertyArray == null || propertyArray.length == 0) { return 0.0; Loading @@ -269,7 +270,7 @@ public class GenericDocument { * false} if there is no such key or the value is of a different type. */ public boolean getPropertyBoolean(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); boolean[] propertyArray = getPropertyBooleanArray(key); if (propertyArray == null || propertyArray.length == 0) { return false; Loading @@ -287,7 +288,7 @@ public class GenericDocument { */ @Nullable public byte[] getPropertyBytes(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); byte[][] propertyArray = getPropertyBytesArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading @@ -305,7 +306,7 @@ public class GenericDocument { */ @Nullable public GenericDocument getPropertyDocument(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); GenericDocument[] propertyArray = getPropertyDocumentArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading Loading @@ -342,7 +343,7 @@ public class GenericDocument { */ @Nullable public String[] getPropertyStringArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, String[].class); } Loading @@ -355,7 +356,7 @@ public class GenericDocument { */ @Nullable public long[] getPropertyLongArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, long[].class); } Loading @@ -368,7 +369,7 @@ public class GenericDocument { */ @Nullable public double[] getPropertyDoubleArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, double[].class); } Loading @@ -381,7 +382,7 @@ public class GenericDocument { */ @Nullable public boolean[] getPropertyBooleanArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, boolean[].class); } Loading @@ -396,7 +397,7 @@ public class GenericDocument { @Nullable @SuppressWarnings("unchecked") public byte[][] getPropertyBytesArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); ArrayList<Bundle> bundles = getAndCastPropertyArray(key, ArrayList.class); if (bundles == null || bundles.size() == 0) { return null; Loading Loading @@ -428,7 +429,7 @@ public class GenericDocument { @SuppressLint("ArrayReturn") @Nullable public GenericDocument[] getPropertyDocumentArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); Parcelable[] bundles = getAndCastPropertyArray(key, Parcelable[].class); if (bundles == null || bundles.length == 0) { return null; Loading Loading @@ -591,9 +592,9 @@ public class GenericDocument { */ @SuppressWarnings("unchecked") public Builder(@NonNull String namespace, @NonNull String uri, @NonNull String schemaType) { Preconditions.checkNotNull(namespace); Preconditions.checkNotNull(uri); Preconditions.checkNotNull(schemaType); Objects.requireNonNull(namespace); Objects.requireNonNull(uri); Objects.requireNonNull(schemaType); mBuilderTypeInstance = (BuilderType) this; mBundle.putString(GenericDocument.NAMESPACE_FIELD, namespace); mBundle.putString(GenericDocument.URI_FIELD, uri); Loading Loading @@ -682,8 +683,8 @@ public class GenericDocument { @NonNull public BuilderType setPropertyString(@NonNull String key, @NonNull String... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -694,15 +695,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code boolean} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyBoolean(@NonNull String key, @NonNull boolean... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -712,15 +712,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code long} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyLong(@NonNull String key, @NonNull long... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -730,15 +729,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code double} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyDouble(@NonNull String key, @NonNull double... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -755,8 +753,8 @@ public class GenericDocument { @NonNull public BuilderType setPropertyBytes(@NonNull String key, @NonNull byte[]... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -776,8 +774,8 @@ public class GenericDocument { public BuilderType setPropertyDocument( @NonNull String key, @NonNull GenericDocument... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading Loading @@ -850,9 +848,7 @@ public class GenericDocument { } private static void validateRepeatedPropertyLength(@NonNull String key, int length) { if (length == 0) { throw new IllegalArgumentException("The input array is empty."); } else if (length > MAX_REPEATED_PROPERTY_LENGTH) { if (length > MAX_REPEATED_PROPERTY_LENGTH) { throw new IllegalArgumentException( "Repeated property \"" + key Loading apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java +10 −9 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** Loading @@ -52,9 +53,9 @@ public final class GetByUriRequest { @NonNull String namespace, @NonNull Set<String> uris, @NonNull Map<String, List<String>> typePropertyPathsMap) { mNamespace = Preconditions.checkNotNull(namespace); mUris = Preconditions.checkNotNull(uris); mTypePropertyPathsMap = Preconditions.checkNotNull(typePropertyPathsMap); mNamespace = Objects.requireNonNull(namespace); mUris = Objects.requireNonNull(uris); mTypePropertyPathsMap = Objects.requireNonNull(typePropertyPathsMap); } /** Returns the namespace attached to the request. */ Loading Loading @@ -114,7 +115,7 @@ public final class GetByUriRequest { /** Creates a {@link GetByUriRequest.Builder} instance. */ public Builder(@NonNull String namespace) { mNamespace = Preconditions.checkNotNull(namespace); mNamespace = Objects.requireNonNull(namespace); } /** Loading @@ -124,7 +125,7 @@ public final class GetByUriRequest { */ @NonNull public Builder addUris(@NonNull String... uris) { Preconditions.checkNotNull(uris); Objects.requireNonNull(uris); return addUris(Arrays.asList(uris)); } Loading @@ -136,7 +137,7 @@ public final class GetByUriRequest { @NonNull public Builder addUris(@NonNull Collection<String> uris) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(uris); Objects.requireNonNull(uris); mUris.addAll(uris); return this; } Loading @@ -161,11 +162,11 @@ public final class GetByUriRequest { public Builder addProjection( @NonNull String schemaType, @NonNull Collection<String> propertyPaths) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(schemaType); Preconditions.checkNotNull(propertyPaths); Objects.requireNonNull(schemaType); Objects.requireNonNull(propertyPaths); List<String> propertyPathsList = new ArrayList<>(propertyPaths.size()); for (String propertyPath : propertyPaths) { Preconditions.checkNotNull(propertyPath); Objects.requireNonNull(propertyPath); propertyPathsList.add(propertyPath); } mProjectionTypePropertyPaths.put(schemaType, propertyPathsList); Loading apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java +2 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.util.ArraySet; import com.android.internal.util.Preconditions; import java.util.ArrayList; import java.util.Objects; import java.util.Set; /** The response class of {@link AppSearchSession#getSchema} */ Loading @@ -34,7 +35,7 @@ public class GetSchemaResponse { private final Bundle mBundle; GetSchemaResponse(@NonNull Bundle bundle) { mBundle = Preconditions.checkNotNull(bundle); mBundle = Objects.requireNonNull(bundle); } /** Loading Loading
apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java +13 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import java.util.Objects; * @param <ValueType> The type of result object for successful calls. */ public final class AppSearchResult<ValueType> implements Parcelable { private static final String TAG = "AppSearchResult"; /** * Result codes from {@link AppSearchSession} methods. * @hide Loading Loading @@ -246,14 +248,22 @@ public final class AppSearchResult<ValueType> implements Parcelable { @NonNull public static <ValueType> AppSearchResult<ValueType> throwableToFailedResult( @NonNull Throwable t) { Log.d("AppSearchResult", "Converting throwable to failed result.", t); // Log for traceability. NOT_FOUND is logged at VERBOSE because this error can occur during // the regular operation of the system (b/183550974). Everything else is logged at DEBUG. if (t instanceof AppSearchException && ((AppSearchException) t).getResultCode() == RESULT_NOT_FOUND) { Log.v(TAG, "Converting throwable to failed result: " + t); } else { Log.d(TAG, "Converting throwable to failed result.", t); } if (t instanceof AppSearchException) { return ((AppSearchException) t).toAppSearchResult(); } String exceptionClass = t.getClass().getSimpleName(); @AppSearchResult.ResultCode int resultCode; if (t instanceof IllegalStateException) { if (t instanceof IllegalStateException || t instanceof NullPointerException) { resultCode = AppSearchResult.RESULT_INTERNAL_ERROR; } else if (t instanceof IllegalArgumentException) { resultCode = AppSearchResult.RESULT_INVALID_ARGUMENT; Loading @@ -262,6 +272,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { } else { resultCode = AppSearchResult.RESULT_UNKNOWN_ERROR; } return AppSearchResult.newFailedResult(resultCode, t.getMessage()); return AppSearchResult.newFailedResult(resultCode, exceptionClass + ": " + t.getMessage()); } }
apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java +6 −6 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ public final class AppSearchSchema { /** @hide */ public AppSearchSchema(@NonNull Bundle bundle) { Preconditions.checkNotNull(bundle); Objects.requireNonNull(bundle); mBundle = bundle; } Loading Loading @@ -125,7 +125,7 @@ public final class AppSearchSchema { /** Creates a new {@link AppSearchSchema.Builder}. */ public Builder(@NonNull String schemaType) { Preconditions.checkNotNull(schemaType); Objects.requireNonNull(schemaType); mSchemaType = schemaType; } Loading @@ -133,7 +133,7 @@ public final class AppSearchSchema { @NonNull public AppSearchSchema.Builder addProperty(@NonNull PropertyConfig propertyConfig) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(propertyConfig); Objects.requireNonNull(propertyConfig); String name = propertyConfig.getName(); if (!mPropertyNames.add(name)) { throw new IllegalSchemaException("Property defined more than once: " + name); Loading Loading @@ -246,7 +246,7 @@ public final class AppSearchSchema { @Nullable private Integer mHashCode; PropertyConfig(@NonNull Bundle bundle) { mBundle = Preconditions.checkNotNull(bundle); mBundle = Objects.requireNonNull(bundle); } @Override Loading Loading @@ -712,7 +712,7 @@ public final class AppSearchSchema { /** Returns the logical schema-type of the contents of this document property. */ @NonNull public String getSchemaType() { return Preconditions.checkNotNull(mBundle.getString(SCHEMA_TYPE_FIELD)); return Objects.requireNonNull(mBundle.getString(SCHEMA_TYPE_FIELD)); } /** Loading Loading @@ -755,7 +755,7 @@ public final class AppSearchSchema { @NonNull public DocumentPropertyConfig.Builder setSchemaType(@NonNull String schemaType) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(schemaType); Objects.requireNonNull(schemaType); mBundle.putString(SCHEMA_TYPE_FIELD, schemaType); return this; } Loading
apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java +37 −41 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Objects; import java.util.Set; /** Loading Loading @@ -101,11 +102,11 @@ public class GenericDocument { * @hide */ public GenericDocument(@NonNull Bundle bundle) { Preconditions.checkNotNull(bundle); Objects.requireNonNull(bundle); mBundle = bundle; mProperties = Preconditions.checkNotNull(bundle.getParcelable(PROPERTIES_FIELD)); mUri = Preconditions.checkNotNull(mBundle.getString(URI_FIELD)); mSchemaType = Preconditions.checkNotNull(mBundle.getString(SCHEMA_TYPE_FIELD)); mProperties = Objects.requireNonNull(bundle.getParcelable(PROPERTIES_FIELD)); mUri = Objects.requireNonNull(mBundle.getString(URI_FIELD)); mSchemaType = Objects.requireNonNull(mBundle.getString(SCHEMA_TYPE_FIELD)); mCreationTimestampMillis = mBundle.getLong(CREATION_TIMESTAMP_MILLIS_FIELD, System.currentTimeMillis()); } Loading Loading @@ -199,7 +200,7 @@ public class GenericDocument { */ @Nullable public Object getProperty(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); Object property = mProperties.get(key); if (property instanceof ArrayList) { return getPropertyBytesArray(key); Loading @@ -218,7 +219,7 @@ public class GenericDocument { */ @Nullable public String getPropertyString(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); String[] propertyArray = getPropertyStringArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading @@ -235,7 +236,7 @@ public class GenericDocument { * there is no such key or the value is of a different type. */ public long getPropertyLong(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); long[] propertyArray = getPropertyLongArray(key); if (propertyArray == null || propertyArray.length == 0) { return 0; Loading @@ -252,7 +253,7 @@ public class GenericDocument { * if there is no such key or the value is of a different type. */ public double getPropertyDouble(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); double[] propertyArray = getPropertyDoubleArray(key); if (propertyArray == null || propertyArray.length == 0) { return 0.0; Loading @@ -269,7 +270,7 @@ public class GenericDocument { * false} if there is no such key or the value is of a different type. */ public boolean getPropertyBoolean(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); boolean[] propertyArray = getPropertyBooleanArray(key); if (propertyArray == null || propertyArray.length == 0) { return false; Loading @@ -287,7 +288,7 @@ public class GenericDocument { */ @Nullable public byte[] getPropertyBytes(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); byte[][] propertyArray = getPropertyBytesArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading @@ -305,7 +306,7 @@ public class GenericDocument { */ @Nullable public GenericDocument getPropertyDocument(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); GenericDocument[] propertyArray = getPropertyDocumentArray(key); if (propertyArray == null || propertyArray.length == 0) { return null; Loading Loading @@ -342,7 +343,7 @@ public class GenericDocument { */ @Nullable public String[] getPropertyStringArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, String[].class); } Loading @@ -355,7 +356,7 @@ public class GenericDocument { */ @Nullable public long[] getPropertyLongArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, long[].class); } Loading @@ -368,7 +369,7 @@ public class GenericDocument { */ @Nullable public double[] getPropertyDoubleArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, double[].class); } Loading @@ -381,7 +382,7 @@ public class GenericDocument { */ @Nullable public boolean[] getPropertyBooleanArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); return getAndCastPropertyArray(key, boolean[].class); } Loading @@ -396,7 +397,7 @@ public class GenericDocument { @Nullable @SuppressWarnings("unchecked") public byte[][] getPropertyBytesArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); ArrayList<Bundle> bundles = getAndCastPropertyArray(key, ArrayList.class); if (bundles == null || bundles.size() == 0) { return null; Loading Loading @@ -428,7 +429,7 @@ public class GenericDocument { @SuppressLint("ArrayReturn") @Nullable public GenericDocument[] getPropertyDocumentArray(@NonNull String key) { Preconditions.checkNotNull(key); Objects.requireNonNull(key); Parcelable[] bundles = getAndCastPropertyArray(key, Parcelable[].class); if (bundles == null || bundles.length == 0) { return null; Loading Loading @@ -591,9 +592,9 @@ public class GenericDocument { */ @SuppressWarnings("unchecked") public Builder(@NonNull String namespace, @NonNull String uri, @NonNull String schemaType) { Preconditions.checkNotNull(namespace); Preconditions.checkNotNull(uri); Preconditions.checkNotNull(schemaType); Objects.requireNonNull(namespace); Objects.requireNonNull(uri); Objects.requireNonNull(schemaType); mBuilderTypeInstance = (BuilderType) this; mBundle.putString(GenericDocument.NAMESPACE_FIELD, namespace); mBundle.putString(GenericDocument.URI_FIELD, uri); Loading Loading @@ -682,8 +683,8 @@ public class GenericDocument { @NonNull public BuilderType setPropertyString(@NonNull String key, @NonNull String... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -694,15 +695,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code boolean} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyBoolean(@NonNull String key, @NonNull boolean... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -712,15 +712,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code long} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyLong(@NonNull String key, @NonNull long... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -730,15 +729,14 @@ public class GenericDocument { * * @param key the key associated with the {@code values}. * @param values the {@code double} values of the property. * @throws IllegalArgumentException if no values are provided or if values exceed maximum * repeated property length. * @throws IllegalArgumentException if values exceed maximum repeated property length. * @throws IllegalStateException if the builder has already been used. */ @NonNull public BuilderType setPropertyDouble(@NonNull String key, @NonNull double... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -755,8 +753,8 @@ public class GenericDocument { @NonNull public BuilderType setPropertyBytes(@NonNull String key, @NonNull byte[]... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading @@ -776,8 +774,8 @@ public class GenericDocument { public BuilderType setPropertyDocument( @NonNull String key, @NonNull GenericDocument... values) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(key); Preconditions.checkNotNull(values); Objects.requireNonNull(key); Objects.requireNonNull(values); putInPropertyBundle(key, values); return mBuilderTypeInstance; } Loading Loading @@ -850,9 +848,7 @@ public class GenericDocument { } private static void validateRepeatedPropertyLength(@NonNull String key, int length) { if (length == 0) { throw new IllegalArgumentException("The input array is empty."); } else if (length > MAX_REPEATED_PROPERTY_LENGTH) { if (length > MAX_REPEATED_PROPERTY_LENGTH) { throw new IllegalArgumentException( "Repeated property \"" + key Loading
apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java +10 −9 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** Loading @@ -52,9 +53,9 @@ public final class GetByUriRequest { @NonNull String namespace, @NonNull Set<String> uris, @NonNull Map<String, List<String>> typePropertyPathsMap) { mNamespace = Preconditions.checkNotNull(namespace); mUris = Preconditions.checkNotNull(uris); mTypePropertyPathsMap = Preconditions.checkNotNull(typePropertyPathsMap); mNamespace = Objects.requireNonNull(namespace); mUris = Objects.requireNonNull(uris); mTypePropertyPathsMap = Objects.requireNonNull(typePropertyPathsMap); } /** Returns the namespace attached to the request. */ Loading Loading @@ -114,7 +115,7 @@ public final class GetByUriRequest { /** Creates a {@link GetByUriRequest.Builder} instance. */ public Builder(@NonNull String namespace) { mNamespace = Preconditions.checkNotNull(namespace); mNamespace = Objects.requireNonNull(namespace); } /** Loading @@ -124,7 +125,7 @@ public final class GetByUriRequest { */ @NonNull public Builder addUris(@NonNull String... uris) { Preconditions.checkNotNull(uris); Objects.requireNonNull(uris); return addUris(Arrays.asList(uris)); } Loading @@ -136,7 +137,7 @@ public final class GetByUriRequest { @NonNull public Builder addUris(@NonNull Collection<String> uris) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(uris); Objects.requireNonNull(uris); mUris.addAll(uris); return this; } Loading @@ -161,11 +162,11 @@ public final class GetByUriRequest { public Builder addProjection( @NonNull String schemaType, @NonNull Collection<String> propertyPaths) { Preconditions.checkState(!mBuilt, "Builder has already been used"); Preconditions.checkNotNull(schemaType); Preconditions.checkNotNull(propertyPaths); Objects.requireNonNull(schemaType); Objects.requireNonNull(propertyPaths); List<String> propertyPathsList = new ArrayList<>(propertyPaths.size()); for (String propertyPath : propertyPaths) { Preconditions.checkNotNull(propertyPath); Objects.requireNonNull(propertyPath); propertyPathsList.add(propertyPath); } mProjectionTypePropertyPaths.put(schemaType, propertyPathsList); Loading
apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java +2 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.util.ArraySet; import com.android.internal.util.Preconditions; import java.util.ArrayList; import java.util.Objects; import java.util.Set; /** The response class of {@link AppSearchSession#getSchema} */ Loading @@ -34,7 +35,7 @@ public class GetSchemaResponse { private final Bundle mBundle; GetSchemaResponse(@NonNull Bundle bundle) { mBundle = Preconditions.checkNotNull(bundle); mBundle = Objects.requireNonNull(bundle); } /** Loading