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