• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.app.appsearch.safeparcel;
18 
19 import android.app.appsearch.AppSearchBlobHandle;
20 import android.app.appsearch.AppSearchSchema;
21 import android.app.appsearch.AppSearchSchema.PropertyConfig.Cardinality;
22 import android.app.appsearch.AppSearchSchema.PropertyConfig.DataType;
23 import android.app.appsearch.AppSearchSchema.StringPropertyConfig.DeletePropagationType;
24 import android.app.appsearch.AppSearchSchema.StringPropertyConfig.JoinableValueType;
25 import android.app.appsearch.AppSearchSchema.StringPropertyConfig.TokenizerType;
26 import android.os.Parcel;
27 import android.os.Parcelable;
28 
29 import org.jspecify.annotations.NonNull;
30 import org.jspecify.annotations.Nullable;
31 
32 import java.util.List;
33 import java.util.Objects;
34 
35 /**
36  * Class to hold property configuration for one property defined in {@link AppSearchSchema}.
37  *
38  * <p>It is defined as same as PropertyConfigProto for the native code to handle different property
39  * types in one class.
40  *
41  * <p>Currently it can handle String, long, double, boolean, bytes and document type.
42  *
43  * @hide
44  */
45 @SafeParcelable.Class(creator = "PropertyConfigParcelCreator")
46 public final class PropertyConfigParcel extends AbstractSafeParcelable {
47     public static final Parcelable.@NonNull Creator<PropertyConfigParcel> CREATOR =
48             new PropertyConfigParcelCreator();
49 
50     @Field(id = 1, getter = "getName")
51     private final String mName;
52 
53     @AppSearchSchema.PropertyConfig.DataType
54     @Field(id = 2, getter = "getDataType")
55     private final int mDataType;
56 
57     @AppSearchSchema.PropertyConfig.Cardinality
58     @Field(id = 3, getter = "getCardinality")
59     private final int mCardinality;
60 
61     @Field(id = 4, getter = "getSchemaType")
62     private final @Nullable String mSchemaType;
63 
64     @Field(id = 5, getter = "getStringIndexingConfigParcel")
65     private final @Nullable StringIndexingConfigParcel mStringIndexingConfigParcel;
66 
67     @Field(id = 6, getter = "getDocumentIndexingConfigParcel")
68     private final @Nullable DocumentIndexingConfigParcel mDocumentIndexingConfigParcel;
69 
70     @Field(id = 7, getter = "getIntegerIndexingConfigParcel")
71     private final @Nullable IntegerIndexingConfigParcel mIntegerIndexingConfigParcel;
72 
73     @Field(id = 8, getter = "getJoinableConfigParcel")
74     private final @Nullable JoinableConfigParcel mJoinableConfigParcel;
75 
76     @Field(id = 9, getter = "getDescription")
77     private final String mDescription;
78 
79     @Field(id = 10, getter = "getEmbeddingIndexingConfigParcel")
80     private final EmbeddingIndexingConfigParcel mEmbeddingIndexingConfigParcel;
81 
82     @Field(id = 11, getter = "isScoringEnabled")
83     private final boolean mScoringEnabled;
84 
85     private @Nullable Integer mHashCode;
86 
87     /** Constructor for {@link PropertyConfigParcel}. */
88     @Constructor
PropertyConfigParcel( @aramid = 1) @onNull String name, @Param(id = 2) @DataType int dataType, @Param(id = 3) @Cardinality int cardinality, @Param(id = 4) @Nullable String schemaType, @Param(id = 5) @Nullable StringIndexingConfigParcel stringIndexingConfigParcel, @Param(id = 6) @Nullable DocumentIndexingConfigParcel documentIndexingConfigParcel, @Param(id = 7) @Nullable IntegerIndexingConfigParcel integerIndexingConfigParcel, @Param(id = 8) @Nullable JoinableConfigParcel joinableConfigParcel, @Param(id = 9) @NonNull String description, @Param(id = 10) @Nullable EmbeddingIndexingConfigParcel embeddingIndexingConfigParcel, @Param(id = 11) boolean scoringEnabled)89     PropertyConfigParcel(
90             @Param(id = 1) @NonNull String name,
91             @Param(id = 2) @DataType int dataType,
92             @Param(id = 3) @Cardinality int cardinality,
93             @Param(id = 4) @Nullable String schemaType,
94             @Param(id = 5) @Nullable StringIndexingConfigParcel stringIndexingConfigParcel,
95             @Param(id = 6) @Nullable DocumentIndexingConfigParcel documentIndexingConfigParcel,
96             @Param(id = 7) @Nullable IntegerIndexingConfigParcel integerIndexingConfigParcel,
97             @Param(id = 8) @Nullable JoinableConfigParcel joinableConfigParcel,
98             @Param(id = 9) @NonNull String description,
99             @Param(id = 10) @Nullable EmbeddingIndexingConfigParcel embeddingIndexingConfigParcel,
100             @Param(id = 11) boolean scoringEnabled) {
101         mName = Objects.requireNonNull(name);
102         mDataType = dataType;
103         mCardinality = cardinality;
104         mSchemaType = schemaType;
105         mStringIndexingConfigParcel = stringIndexingConfigParcel;
106         mDocumentIndexingConfigParcel = documentIndexingConfigParcel;
107         mIntegerIndexingConfigParcel = integerIndexingConfigParcel;
108         mJoinableConfigParcel = joinableConfigParcel;
109         mDescription = Objects.requireNonNull(description);
110         mEmbeddingIndexingConfigParcel = embeddingIndexingConfigParcel;
111         mScoringEnabled = scoringEnabled;
112     }
113 
114     /** Creates a {@link PropertyConfigParcel} for String. */
createForString( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, @NonNull StringIndexingConfigParcel stringIndexingConfigParcel, @NonNull JoinableConfigParcel joinableConfigParcel)115     public static @NonNull PropertyConfigParcel createForString(
116             @NonNull String propertyName,
117             @NonNull String description,
118             @Cardinality int cardinality,
119             @NonNull StringIndexingConfigParcel stringIndexingConfigParcel,
120             @NonNull JoinableConfigParcel joinableConfigParcel) {
121         return new PropertyConfigParcel(
122                 Objects.requireNonNull(propertyName),
123                 AppSearchSchema.PropertyConfig.DATA_TYPE_STRING,
124                 cardinality,
125                 /* schemaType= */ null,
126                 Objects.requireNonNull(stringIndexingConfigParcel),
127                 /* documentIndexingConfigParcel= */ null,
128                 /* integerIndexingConfigParcel= */ null,
129                 Objects.requireNonNull(joinableConfigParcel),
130                 Objects.requireNonNull(description),
131                 /* embeddingIndexingConfigParcel= */ null,
132                 /* scoringEnabled= */ false);
133     }
134 
135     /** Creates a {@link PropertyConfigParcel} for Long. */
createForLong( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, @AppSearchSchema.LongPropertyConfig.IndexingType int indexingType, boolean scoringEnabled)136     public static @NonNull PropertyConfigParcel createForLong(
137             @NonNull String propertyName,
138             @NonNull String description,
139             @Cardinality int cardinality,
140             @AppSearchSchema.LongPropertyConfig.IndexingType int indexingType,
141             boolean scoringEnabled) {
142         return new PropertyConfigParcel(
143                 Objects.requireNonNull(propertyName),
144                 AppSearchSchema.PropertyConfig.DATA_TYPE_LONG,
145                 cardinality,
146                 /* schemaType= */ null,
147                 /* stringIndexingConfigParcel= */ null,
148                 /* documentIndexingConfigParcel= */ null,
149                 new IntegerIndexingConfigParcel(indexingType),
150                 /* joinableConfigParcel= */ null,
151                 Objects.requireNonNull(description),
152                 /* embeddingIndexingConfigParcel= */ null,
153                 scoringEnabled);
154     }
155 
156     /** Creates a {@link PropertyConfigParcel} for Double. */
createForDouble( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, boolean scoringEnabled)157     public static @NonNull PropertyConfigParcel createForDouble(
158             @NonNull String propertyName,
159             @NonNull String description,
160             @Cardinality int cardinality,
161             boolean scoringEnabled) {
162         return new PropertyConfigParcel(
163                 Objects.requireNonNull(propertyName),
164                 AppSearchSchema.PropertyConfig.DATA_TYPE_DOUBLE,
165                 cardinality,
166                 /* schemaType= */ null,
167                 /* stringIndexingConfigParcel= */ null,
168                 /* documentIndexingConfigParcel= */ null,
169                 /* integerIndexingConfigParcel= */ null,
170                 /* joinableConfigParcel= */ null,
171                 Objects.requireNonNull(description),
172                 /* embeddingIndexingConfigParcel= */ null,
173                 scoringEnabled);
174     }
175 
176     /** Creates a {@link PropertyConfigParcel} for Boolean. */
createForBoolean( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, boolean scoringEnabled)177     public static @NonNull PropertyConfigParcel createForBoolean(
178             @NonNull String propertyName,
179             @NonNull String description,
180             @Cardinality int cardinality,
181             boolean scoringEnabled) {
182         return new PropertyConfigParcel(
183                 Objects.requireNonNull(propertyName),
184                 AppSearchSchema.PropertyConfig.DATA_TYPE_BOOLEAN,
185                 cardinality,
186                 /* schemaType= */ null,
187                 /* stringIndexingConfigParcel= */ null,
188                 /* documentIndexingConfigParcel= */ null,
189                 /* integerIndexingConfigParcel= */ null,
190                 /* joinableConfigParcel= */ null,
191                 Objects.requireNonNull(description),
192                 /* embeddingIndexingConfigParcel= */ null,
193                 scoringEnabled);
194     }
195 
196     /** Creates a {@link PropertyConfigParcel} for Bytes. */
createForBytes( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality)197     public static @NonNull PropertyConfigParcel createForBytes(
198             @NonNull String propertyName,
199             @NonNull String description,
200             @Cardinality int cardinality) {
201         return new PropertyConfigParcel(
202                 Objects.requireNonNull(propertyName),
203                 AppSearchSchema.PropertyConfig.DATA_TYPE_BYTES,
204                 cardinality,
205                 /* schemaType= */ null,
206                 /* stringIndexingConfigParcel= */ null,
207                 /* documentIndexingConfigParcel= */ null,
208                 /* integerIndexingConfigParcel= */ null,
209                 /* joinableConfigParcel= */ null,
210                 Objects.requireNonNull(description),
211                 /* embeddingIndexingConfigParcel= */ null,
212                 /* scoringEnabled= */ false);
213     }
214 
215     /** Creates a {@link PropertyConfigParcel} for Document. */
createForDocument( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, @NonNull String schemaType, @NonNull DocumentIndexingConfigParcel documentIndexingConfigParcel)216     public static @NonNull PropertyConfigParcel createForDocument(
217             @NonNull String propertyName,
218             @NonNull String description,
219             @Cardinality int cardinality,
220             @NonNull String schemaType,
221             @NonNull DocumentIndexingConfigParcel documentIndexingConfigParcel) {
222         return new PropertyConfigParcel(
223                 Objects.requireNonNull(propertyName),
224                 AppSearchSchema.PropertyConfig.DATA_TYPE_DOCUMENT,
225                 cardinality,
226                 Objects.requireNonNull(schemaType),
227                 /* stringIndexingConfigParcel= */ null,
228                 Objects.requireNonNull(documentIndexingConfigParcel),
229                 /* integerIndexingConfigParcel= */ null,
230                 /* joinableConfigParcel= */ null,
231                 Objects.requireNonNull(description),
232                 /* embeddingIndexingConfigParcel= */ null,
233                 /* scoringEnabled= */ false);
234     }
235 
236     /** Creates a {@link PropertyConfigParcel} for Embedding. */
createForEmbedding( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality, @AppSearchSchema.EmbeddingPropertyConfig.IndexingType int indexingType, @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType int quantizationType)237     public static @NonNull PropertyConfigParcel createForEmbedding(
238             @NonNull String propertyName,
239             @NonNull String description,
240             @Cardinality int cardinality,
241             @AppSearchSchema.EmbeddingPropertyConfig.IndexingType int indexingType,
242             @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType int quantizationType) {
243         return new PropertyConfigParcel(
244                 Objects.requireNonNull(propertyName),
245                 AppSearchSchema.PropertyConfig.DATA_TYPE_EMBEDDING,
246                 cardinality,
247                 /* schemaType= */ null,
248                 /* stringIndexingConfigParcel= */ null,
249                 /* documentIndexingConfigParcel= */ null,
250                 /* integerIndexingConfigParcel= */ null,
251                 /* joinableConfigParcel= */ null,
252                 Objects.requireNonNull(description),
253                 new EmbeddingIndexingConfigParcel(indexingType, quantizationType),
254                 /* scoringEnabled= */ false);
255     }
256 
257     /** Creates a {@link PropertyConfigParcel} for {@link AppSearchBlobHandle}. */
createForBlobHandle( @onNull String propertyName, @NonNull String description, @Cardinality int cardinality)258     public static @NonNull PropertyConfigParcel createForBlobHandle(
259             @NonNull String propertyName,
260             @NonNull String description,
261             @Cardinality int cardinality) {
262         return new PropertyConfigParcel(
263                 Objects.requireNonNull(propertyName),
264                 AppSearchSchema.PropertyConfig.DATA_TYPE_BLOB_HANDLE,
265                 cardinality,
266                 /* schemaType= */ null,
267                 /* stringIndexingConfigParcel= */ null,
268                 /* documentIndexingConfigParcel= */ null,
269                 /* integerIndexingConfigParcel= */ null,
270                 /* joinableConfigParcel= */ null,
271                 Objects.requireNonNull(description),
272                 /* embeddingIndexingConfigParcel= */ null,
273                 /* scoringEnabled= */ false);
274     }
275 
276     /** Gets name for the property. */
getName()277     public @NonNull String getName() {
278         return mName;
279     }
280 
281     /** Gets description for the property. */
getDescription()282     public @NonNull String getDescription() {
283         return mDescription;
284     }
285 
286     /** Gets data type for the property. */
287     @DataType
getDataType()288     public int getDataType() {
289         return mDataType;
290     }
291 
292     /** Gets cardinality for the property. */
293     @Cardinality
getCardinality()294     public int getCardinality() {
295         return mCardinality;
296     }
297 
298     /** Gets schema type. */
getSchemaType()299     public @Nullable String getSchemaType() {
300         return mSchemaType;
301     }
302 
303     /** Gets the {@link StringIndexingConfigParcel}. */
getStringIndexingConfigParcel()304     public @Nullable StringIndexingConfigParcel getStringIndexingConfigParcel() {
305         return mStringIndexingConfigParcel;
306     }
307 
308     /** Gets the {@link DocumentIndexingConfigParcel}. */
getDocumentIndexingConfigParcel()309     public @Nullable DocumentIndexingConfigParcel getDocumentIndexingConfigParcel() {
310         return mDocumentIndexingConfigParcel;
311     }
312 
313     /** Gets the {@link IntegerIndexingConfigParcel}. */
getIntegerIndexingConfigParcel()314     public @Nullable IntegerIndexingConfigParcel getIntegerIndexingConfigParcel() {
315         return mIntegerIndexingConfigParcel;
316     }
317 
318     /** Gets the {@link JoinableConfigParcel}. */
getJoinableConfigParcel()319     public @Nullable JoinableConfigParcel getJoinableConfigParcel() {
320         return mJoinableConfigParcel;
321     }
322 
323     /** Gets the {@link EmbeddingIndexingConfigParcel}. */
getEmbeddingIndexingConfigParcel()324     public @Nullable EmbeddingIndexingConfigParcel getEmbeddingIndexingConfigParcel() {
325         return mEmbeddingIndexingConfigParcel;
326     }
327 
328     /** Gets ScorableType for the property. */
isScoringEnabled()329     public boolean isScoringEnabled() {
330         return mScoringEnabled;
331     }
332 
333     @Override
writeToParcel(@onNull Parcel dest, int flags)334     public void writeToParcel(@NonNull Parcel dest, int flags) {
335         PropertyConfigParcelCreator.writeToParcel(this, dest, flags);
336     }
337 
338     @Override
equals(@ullable Object other)339     public boolean equals(@Nullable Object other) {
340         if (this == other) {
341             return true;
342         }
343         if (!(other instanceof PropertyConfigParcel)) {
344             return false;
345         }
346         PropertyConfigParcel otherProperty = (PropertyConfigParcel) other;
347         return Objects.equals(mName, otherProperty.mName)
348                 && Objects.equals(mDescription, otherProperty.mDescription)
349                 && Objects.equals(mDataType, otherProperty.mDataType)
350                 && Objects.equals(mCardinality, otherProperty.mCardinality)
351                 && Objects.equals(mSchemaType, otherProperty.mSchemaType)
352                 && Objects.equals(
353                         mStringIndexingConfigParcel, otherProperty.mStringIndexingConfigParcel)
354                 && Objects.equals(
355                         mDocumentIndexingConfigParcel, otherProperty.mDocumentIndexingConfigParcel)
356                 && Objects.equals(
357                         mIntegerIndexingConfigParcel, otherProperty.mIntegerIndexingConfigParcel)
358                 && Objects.equals(mJoinableConfigParcel, otherProperty.mJoinableConfigParcel)
359                 && Objects.equals(
360                         mEmbeddingIndexingConfigParcel,
361                         otherProperty.mEmbeddingIndexingConfigParcel)
362                 && mScoringEnabled == otherProperty.mScoringEnabled;
363     }
364 
365     @Override
hashCode()366     public int hashCode() {
367         if (mHashCode == null) {
368             mHashCode =
369                     Objects.hash(
370                             mName,
371                             mDescription,
372                             mDataType,
373                             mCardinality,
374                             mSchemaType,
375                             mStringIndexingConfigParcel,
376                             mDocumentIndexingConfigParcel,
377                             mIntegerIndexingConfigParcel,
378                             mJoinableConfigParcel,
379                             mEmbeddingIndexingConfigParcel,
380                             mScoringEnabled);
381         }
382         return mHashCode;
383     }
384 
385     @Override
toString()386     public @NonNull String toString() {
387         return "{name: "
388                 + mName
389                 + ", description: "
390                 + mDescription
391                 + ", dataType: "
392                 + mDataType
393                 + ", cardinality: "
394                 + mCardinality
395                 + ", schemaType: "
396                 + mSchemaType
397                 + ", stringIndexingConfigParcel: "
398                 + mStringIndexingConfigParcel
399                 + ", documentIndexingConfigParcel: "
400                 + mDocumentIndexingConfigParcel
401                 + ", integerIndexingConfigParcel: "
402                 + mIntegerIndexingConfigParcel
403                 + ", joinableConfigParcel: "
404                 + mJoinableConfigParcel
405                 + ", embeddingIndexingConfigParcel: "
406                 + mEmbeddingIndexingConfigParcel
407                 + ", isScoringEnabled: "
408                 + mScoringEnabled
409                 + "}";
410     }
411 
412     /** Class to hold join configuration for a String type. */
413     @SafeParcelable.Class(creator = "JoinableConfigParcelCreator")
414     public static class JoinableConfigParcel extends AbstractSafeParcelable {
415         public static final Parcelable.@NonNull Creator<JoinableConfigParcel> CREATOR =
416                 new JoinableConfigParcelCreator();
417 
418         @JoinableValueType
419         @Field(id = 1, getter = "getJoinableValueType")
420         private final int mJoinableValueType;
421 
422         @Field(id = 3, getter = "getDeletePropagationType")
423         private final int mDeletePropagationType;
424 
425         /** Constructor for {@link JoinableConfigParcel}. */
426         @Constructor
JoinableConfigParcel( @aramid = 1) @oinableValueType int joinableValueType, @Param(id = 3) @DeletePropagationType int deletePropagationType)427         public JoinableConfigParcel(
428                 @Param(id = 1) @JoinableValueType int joinableValueType,
429                 @Param(id = 3) @DeletePropagationType int deletePropagationType) {
430             mJoinableValueType = joinableValueType;
431             mDeletePropagationType = deletePropagationType;
432         }
433 
434         /** Gets {@link JoinableValueType} of the join. */
435         @JoinableValueType
getJoinableValueType()436         public int getJoinableValueType() {
437             return mJoinableValueType;
438         }
439 
440         /** Gets {@link DeletePropagationType} of the join. */
441         @DeletePropagationType
getDeletePropagationType()442         public int getDeletePropagationType() {
443             return mDeletePropagationType;
444         }
445 
446         @Override
writeToParcel(@onNull Parcel dest, int flags)447         public void writeToParcel(@NonNull Parcel dest, int flags) {
448             JoinableConfigParcelCreator.writeToParcel(this, dest, flags);
449         }
450 
451         @Override
hashCode()452         public int hashCode() {
453             return Objects.hash(mJoinableValueType, mDeletePropagationType);
454         }
455 
456         @Override
equals(@ullable Object other)457         public boolean equals(@Nullable Object other) {
458             if (this == other) {
459                 return true;
460             }
461             if (!(other instanceof JoinableConfigParcel)) {
462                 return false;
463             }
464             JoinableConfigParcel otherObject = (JoinableConfigParcel) other;
465             return Objects.equals(mJoinableValueType, otherObject.mJoinableValueType)
466                     && mDeletePropagationType == otherObject.mDeletePropagationType;
467         }
468 
469         @Override
toString()470         public @NonNull String toString() {
471             return "{joinableValueType: "
472                     + mJoinableValueType
473                     + ", deletePropagationType: "
474                     + mDeletePropagationType
475                     + "}";
476         }
477     }
478 
479     /** Class to hold configuration a string type. */
480     @SafeParcelable.Class(creator = "StringIndexingConfigParcelCreator")
481     public static class StringIndexingConfigParcel extends AbstractSafeParcelable {
482         public static final Parcelable.@NonNull Creator<StringIndexingConfigParcel> CREATOR =
483                 new StringIndexingConfigParcelCreator();
484 
485         @AppSearchSchema.StringPropertyConfig.IndexingType
486         @Field(id = 1, getter = "getIndexingType")
487         private final int mIndexingType;
488 
489         @TokenizerType
490         @Field(id = 2, getter = "getTokenizerType")
491         private final int mTokenizerType;
492 
493         /** Constructor for {@link StringIndexingConfigParcel}. */
494         @Constructor
StringIndexingConfigParcel( @aramid = 1) @ppSearchSchema.StringPropertyConfig.IndexingType int indexingType, @Param(id = 2) @TokenizerType int tokenizerType)495         public StringIndexingConfigParcel(
496                 @Param(id = 1) @AppSearchSchema.StringPropertyConfig.IndexingType int indexingType,
497                 @Param(id = 2) @TokenizerType int tokenizerType) {
498             mIndexingType = indexingType;
499             mTokenizerType = tokenizerType;
500         }
501 
502         /** Gets the indexing type for this property. */
503         @AppSearchSchema.StringPropertyConfig.IndexingType
getIndexingType()504         public int getIndexingType() {
505             return mIndexingType;
506         }
507 
508         /** Gets the tokenization type for this property. */
509         @TokenizerType
getTokenizerType()510         public int getTokenizerType() {
511             return mTokenizerType;
512         }
513 
514         @Override
writeToParcel(@onNull Parcel dest, int flags)515         public void writeToParcel(@NonNull Parcel dest, int flags) {
516             StringIndexingConfigParcelCreator.writeToParcel(this, dest, flags);
517         }
518 
519         @Override
hashCode()520         public int hashCode() {
521             return Objects.hash(mIndexingType, mTokenizerType);
522         }
523 
524         @Override
equals(@ullable Object other)525         public boolean equals(@Nullable Object other) {
526             if (this == other) {
527                 return true;
528             }
529             if (!(other instanceof StringIndexingConfigParcel)) {
530                 return false;
531             }
532             StringIndexingConfigParcel otherObject = (StringIndexingConfigParcel) other;
533             return mIndexingType == otherObject.mIndexingType
534                     && Objects.equals(mTokenizerType, otherObject.mTokenizerType);
535         }
536 
537         @Override
toString()538         public @NonNull String toString() {
539             return "{indexingType: " + mIndexingType + ", tokenizerType: " + mTokenizerType + "}";
540         }
541     }
542 
543     /** Class to hold configuration for integer property type. */
544     @SafeParcelable.Class(creator = "IntegerIndexingConfigParcelCreator")
545     public static class IntegerIndexingConfigParcel extends AbstractSafeParcelable {
546         public static final Parcelable.@NonNull Creator<IntegerIndexingConfigParcel> CREATOR =
547                 new IntegerIndexingConfigParcelCreator();
548 
549         @AppSearchSchema.LongPropertyConfig.IndexingType
550         @Field(id = 1, getter = "getIndexingType")
551         private final int mIndexingType;
552 
553         /** Constructor for {@link IntegerIndexingConfigParcel}. */
554         @Constructor
IntegerIndexingConfigParcel( @aramid = 1) @ppSearchSchema.LongPropertyConfig.IndexingType int indexingType)555         public IntegerIndexingConfigParcel(
556                 @Param(id = 1) @AppSearchSchema.LongPropertyConfig.IndexingType int indexingType) {
557             mIndexingType = indexingType;
558         }
559 
560         /** Gets the indexing type for this integer property. */
561         @AppSearchSchema.LongPropertyConfig.IndexingType
getIndexingType()562         public int getIndexingType() {
563             return mIndexingType;
564         }
565 
566         @Override
writeToParcel(@onNull Parcel dest, int flags)567         public void writeToParcel(@NonNull Parcel dest, int flags) {
568             IntegerIndexingConfigParcelCreator.writeToParcel(this, dest, flags);
569         }
570 
571         @Override
hashCode()572         public int hashCode() {
573             return Objects.hashCode(mIndexingType);
574         }
575 
576         @Override
equals(@ullable Object other)577         public boolean equals(@Nullable Object other) {
578             if (this == other) {
579                 return true;
580             }
581             if (!(other instanceof IntegerIndexingConfigParcel)) {
582                 return false;
583             }
584             IntegerIndexingConfigParcel otherObject = (IntegerIndexingConfigParcel) other;
585             return mIndexingType == otherObject.mIndexingType;
586         }
587 
588         @Override
toString()589         public @NonNull String toString() {
590             return "{indexingType: " + mIndexingType + "}";
591         }
592     }
593 
594     /** Class to hold configuration for document property type. */
595     @SafeParcelable.Class(creator = "DocumentIndexingConfigParcelCreator")
596     public static class DocumentIndexingConfigParcel extends AbstractSafeParcelable {
597         public static final Parcelable.@NonNull Creator<DocumentIndexingConfigParcel> CREATOR =
598                 new DocumentIndexingConfigParcelCreator();
599 
600         @Field(id = 1, getter = "shouldIndexNestedProperties")
601         private final boolean mIndexNestedProperties;
602 
603         @Field(id = 2, getter = "getIndexableNestedPropertiesList")
604         private final @NonNull List<String> mIndexableNestedPropertiesList;
605 
606         /** Constructor for {@link DocumentIndexingConfigParcel}. */
607         @Constructor
DocumentIndexingConfigParcel( @aramid = 1) boolean indexNestedProperties, @Param(id = 2) @NonNull List<String> indexableNestedPropertiesList)608         public DocumentIndexingConfigParcel(
609                 @Param(id = 1) boolean indexNestedProperties,
610                 @Param(id = 2) @NonNull List<String> indexableNestedPropertiesList) {
611             mIndexNestedProperties = indexNestedProperties;
612             mIndexableNestedPropertiesList = Objects.requireNonNull(indexableNestedPropertiesList);
613         }
614 
615         /** Nested properties should be indexed. */
shouldIndexNestedProperties()616         public boolean shouldIndexNestedProperties() {
617             return mIndexNestedProperties;
618         }
619 
620         /** Gets the list for nested property list. */
getIndexableNestedPropertiesList()621         public @NonNull List<String> getIndexableNestedPropertiesList() {
622             return mIndexableNestedPropertiesList;
623         }
624 
625         @Override
writeToParcel(@onNull Parcel dest, int flags)626         public void writeToParcel(@NonNull Parcel dest, int flags) {
627             DocumentIndexingConfigParcelCreator.writeToParcel(this, dest, flags);
628         }
629 
630         @Override
hashCode()631         public int hashCode() {
632             return Objects.hash(mIndexNestedProperties, mIndexableNestedPropertiesList);
633         }
634 
635         @Override
equals(@ullable Object other)636         public boolean equals(@Nullable Object other) {
637             if (this == other) {
638                 return true;
639             }
640             if (!(other instanceof DocumentIndexingConfigParcel)) {
641                 return false;
642             }
643             DocumentIndexingConfigParcel otherObject = (DocumentIndexingConfigParcel) other;
644             return Objects.equals(mIndexNestedProperties, otherObject.mIndexNestedProperties)
645                     && Objects.equals(
646                             mIndexableNestedPropertiesList,
647                             otherObject.mIndexableNestedPropertiesList);
648         }
649 
650         @Override
toString()651         public @NonNull String toString() {
652             return "{indexNestedProperties: "
653                     + mIndexNestedProperties
654                     + ", indexableNestedPropertiesList: "
655                     + mIndexableNestedPropertiesList
656                     + "}";
657         }
658     }
659 
660     /** Class to hold configuration for embedding property. */
661     @SafeParcelable.Class(creator = "EmbeddingIndexingConfigParcelCreator")
662     public static class EmbeddingIndexingConfigParcel extends AbstractSafeParcelable {
663         public static final Parcelable.@NonNull Creator<EmbeddingIndexingConfigParcel> CREATOR =
664                 new EmbeddingIndexingConfigParcelCreator();
665 
666         @AppSearchSchema.EmbeddingPropertyConfig.IndexingType
667         @Field(id = 1, getter = "getIndexingType")
668         private final int mIndexingType;
669 
670         @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType
671         @Field(id = 2, getter = "getQuantizationType")
672         private final int mQuantizationType;
673 
674         /** Constructor for {@link EmbeddingIndexingConfigParcel}. */
675         @Constructor
EmbeddingIndexingConfigParcel( @aramid = 1) @ppSearchSchema.EmbeddingPropertyConfig.IndexingType int indexingType, @Param(id = 2) @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType int quantizationType)676         public EmbeddingIndexingConfigParcel(
677                 @Param(id = 1) @AppSearchSchema.EmbeddingPropertyConfig.IndexingType
678                         int indexingType,
679                 @Param(id = 2) @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType
680                         int quantizationType) {
681             mIndexingType = indexingType;
682             mQuantizationType = quantizationType;
683         }
684 
685         /** Gets the indexing type for this embedding property. */
686         @AppSearchSchema.EmbeddingPropertyConfig.IndexingType
getIndexingType()687         public int getIndexingType() {
688             return mIndexingType;
689         }
690 
691         /** Gets the quantization type for this embedding property. */
692         @AppSearchSchema.EmbeddingPropertyConfig.QuantizationType
getQuantizationType()693         public int getQuantizationType() {
694             return mQuantizationType;
695         }
696 
697         @Override
writeToParcel(@onNull Parcel dest, int flags)698         public void writeToParcel(@NonNull Parcel dest, int flags) {
699             EmbeddingIndexingConfigParcelCreator.writeToParcel(this, dest, flags);
700         }
701 
702         @Override
hashCode()703         public int hashCode() {
704             return Objects.hash(mIndexingType, mQuantizationType);
705         }
706 
707         @Override
equals(@ullable Object other)708         public boolean equals(@Nullable Object other) {
709             if (this == other) {
710                 return true;
711             }
712             if (!(other instanceof EmbeddingIndexingConfigParcel)) {
713                 return false;
714             }
715             EmbeddingIndexingConfigParcel otherObject = (EmbeddingIndexingConfigParcel) other;
716             return mIndexingType == otherObject.mIndexingType
717                     && mQuantizationType == otherObject.mQuantizationType;
718         }
719 
720         @Override
toString()721         public @NonNull String toString() {
722             return "{indexingType: "
723                     + mIndexingType
724                     + ", quantizationType: "
725                     + mQuantizationType
726                     + "}";
727         }
728     }
729 }
730