1 /* 2 * Copyright 2020 Google LLC 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 * https://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 // Generated by the protocol buffer compiler. DO NOT EDIT! 17 // source: google/cloud/retail/v2/common.proto 18 19 package com.google.cloud.retail.v2; 20 21 /** 22 * 23 * 24 * <pre> 25 * The rating of a [Product][google.cloud.retail.v2.Product]. 26 * </pre> 27 * 28 * Protobuf type {@code google.cloud.retail.v2.Rating} 29 */ 30 public final class Rating extends com.google.protobuf.GeneratedMessageV3 31 implements 32 // @@protoc_insertion_point(message_implements:google.cloud.retail.v2.Rating) 33 RatingOrBuilder { 34 private static final long serialVersionUID = 0L; 35 // Use Rating.newBuilder() to construct. Rating(com.google.protobuf.GeneratedMessageV3.Builder<?> builder)36 private Rating(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { 37 super(builder); 38 } 39 Rating()40 private Rating() { 41 ratingHistogram_ = emptyIntList(); 42 } 43 44 @java.lang.Override 45 @SuppressWarnings({"unused"}) newInstance(UnusedPrivateParameter unused)46 protected java.lang.Object newInstance(UnusedPrivateParameter unused) { 47 return new Rating(); 48 } 49 50 @java.lang.Override getUnknownFields()51 public final com.google.protobuf.UnknownFieldSet getUnknownFields() { 52 return this.unknownFields; 53 } 54 getDescriptor()55 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 56 return com.google.cloud.retail.v2.CommonProto 57 .internal_static_google_cloud_retail_v2_Rating_descriptor; 58 } 59 60 @java.lang.Override 61 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()62 internalGetFieldAccessorTable() { 63 return com.google.cloud.retail.v2.CommonProto 64 .internal_static_google_cloud_retail_v2_Rating_fieldAccessorTable 65 .ensureFieldAccessorsInitialized( 66 com.google.cloud.retail.v2.Rating.class, 67 com.google.cloud.retail.v2.Rating.Builder.class); 68 } 69 70 public static final int RATING_COUNT_FIELD_NUMBER = 1; 71 private int ratingCount_ = 0; 72 /** 73 * 74 * 75 * <pre> 76 * The total number of ratings. This value is independent of the value of 77 * [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. 78 * This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is 79 * returned. 80 * </pre> 81 * 82 * <code>int32 rating_count = 1;</code> 83 * 84 * @return The ratingCount. 85 */ 86 @java.lang.Override getRatingCount()87 public int getRatingCount() { 88 return ratingCount_; 89 } 90 91 public static final int AVERAGE_RATING_FIELD_NUMBER = 2; 92 private float averageRating_ = 0F; 93 /** 94 * 95 * 96 * <pre> 97 * The average rating of the [Product][google.cloud.retail.v2.Product]. 98 * The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is 99 * returned. 100 * </pre> 101 * 102 * <code>float average_rating = 2;</code> 103 * 104 * @return The averageRating. 105 */ 106 @java.lang.Override getAverageRating()107 public float getAverageRating() { 108 return averageRating_; 109 } 110 111 public static final int RATING_HISTOGRAM_FIELD_NUMBER = 3; 112 113 @SuppressWarnings("serial") 114 private com.google.protobuf.Internal.IntList ratingHistogram_; 115 /** 116 * 117 * 118 * <pre> 119 * List of rating counts per rating value (index = rating - 1). The list is 120 * empty if there is no rating. If the list is non-empty, its size is 121 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 122 * For example, [41, 14, 13, 47, 303]. It means that the 123 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 124 * ratings with 2 star, and so on. 125 * </pre> 126 * 127 * <code>repeated int32 rating_histogram = 3;</code> 128 * 129 * @return A list containing the ratingHistogram. 130 */ 131 @java.lang.Override getRatingHistogramList()132 public java.util.List<java.lang.Integer> getRatingHistogramList() { 133 return ratingHistogram_; 134 } 135 /** 136 * 137 * 138 * <pre> 139 * List of rating counts per rating value (index = rating - 1). The list is 140 * empty if there is no rating. If the list is non-empty, its size is 141 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 142 * For example, [41, 14, 13, 47, 303]. It means that the 143 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 144 * ratings with 2 star, and so on. 145 * </pre> 146 * 147 * <code>repeated int32 rating_histogram = 3;</code> 148 * 149 * @return The count of ratingHistogram. 150 */ getRatingHistogramCount()151 public int getRatingHistogramCount() { 152 return ratingHistogram_.size(); 153 } 154 /** 155 * 156 * 157 * <pre> 158 * List of rating counts per rating value (index = rating - 1). The list is 159 * empty if there is no rating. If the list is non-empty, its size is 160 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 161 * For example, [41, 14, 13, 47, 303]. It means that the 162 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 163 * ratings with 2 star, and so on. 164 * </pre> 165 * 166 * <code>repeated int32 rating_histogram = 3;</code> 167 * 168 * @param index The index of the element to return. 169 * @return The ratingHistogram at the given index. 170 */ getRatingHistogram(int index)171 public int getRatingHistogram(int index) { 172 return ratingHistogram_.getInt(index); 173 } 174 175 private int ratingHistogramMemoizedSerializedSize = -1; 176 177 private byte memoizedIsInitialized = -1; 178 179 @java.lang.Override isInitialized()180 public final boolean isInitialized() { 181 byte isInitialized = memoizedIsInitialized; 182 if (isInitialized == 1) return true; 183 if (isInitialized == 0) return false; 184 185 memoizedIsInitialized = 1; 186 return true; 187 } 188 189 @java.lang.Override writeTo(com.google.protobuf.CodedOutputStream output)190 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { 191 getSerializedSize(); 192 if (ratingCount_ != 0) { 193 output.writeInt32(1, ratingCount_); 194 } 195 if (java.lang.Float.floatToRawIntBits(averageRating_) != 0) { 196 output.writeFloat(2, averageRating_); 197 } 198 if (getRatingHistogramList().size() > 0) { 199 output.writeUInt32NoTag(26); 200 output.writeUInt32NoTag(ratingHistogramMemoizedSerializedSize); 201 } 202 for (int i = 0; i < ratingHistogram_.size(); i++) { 203 output.writeInt32NoTag(ratingHistogram_.getInt(i)); 204 } 205 getUnknownFields().writeTo(output); 206 } 207 208 @java.lang.Override getSerializedSize()209 public int getSerializedSize() { 210 int size = memoizedSize; 211 if (size != -1) return size; 212 213 size = 0; 214 if (ratingCount_ != 0) { 215 size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, ratingCount_); 216 } 217 if (java.lang.Float.floatToRawIntBits(averageRating_) != 0) { 218 size += com.google.protobuf.CodedOutputStream.computeFloatSize(2, averageRating_); 219 } 220 { 221 int dataSize = 0; 222 for (int i = 0; i < ratingHistogram_.size(); i++) { 223 dataSize += 224 com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(ratingHistogram_.getInt(i)); 225 } 226 size += dataSize; 227 if (!getRatingHistogramList().isEmpty()) { 228 size += 1; 229 size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); 230 } 231 ratingHistogramMemoizedSerializedSize = dataSize; 232 } 233 size += getUnknownFields().getSerializedSize(); 234 memoizedSize = size; 235 return size; 236 } 237 238 @java.lang.Override equals(final java.lang.Object obj)239 public boolean equals(final java.lang.Object obj) { 240 if (obj == this) { 241 return true; 242 } 243 if (!(obj instanceof com.google.cloud.retail.v2.Rating)) { 244 return super.equals(obj); 245 } 246 com.google.cloud.retail.v2.Rating other = (com.google.cloud.retail.v2.Rating) obj; 247 248 if (getRatingCount() != other.getRatingCount()) return false; 249 if (java.lang.Float.floatToIntBits(getAverageRating()) 250 != java.lang.Float.floatToIntBits(other.getAverageRating())) return false; 251 if (!getRatingHistogramList().equals(other.getRatingHistogramList())) return false; 252 if (!getUnknownFields().equals(other.getUnknownFields())) return false; 253 return true; 254 } 255 256 @java.lang.Override hashCode()257 public int hashCode() { 258 if (memoizedHashCode != 0) { 259 return memoizedHashCode; 260 } 261 int hash = 41; 262 hash = (19 * hash) + getDescriptor().hashCode(); 263 hash = (37 * hash) + RATING_COUNT_FIELD_NUMBER; 264 hash = (53 * hash) + getRatingCount(); 265 hash = (37 * hash) + AVERAGE_RATING_FIELD_NUMBER; 266 hash = (53 * hash) + java.lang.Float.floatToIntBits(getAverageRating()); 267 if (getRatingHistogramCount() > 0) { 268 hash = (37 * hash) + RATING_HISTOGRAM_FIELD_NUMBER; 269 hash = (53 * hash) + getRatingHistogramList().hashCode(); 270 } 271 hash = (29 * hash) + getUnknownFields().hashCode(); 272 memoizedHashCode = hash; 273 return hash; 274 } 275 parseFrom(java.nio.ByteBuffer data)276 public static com.google.cloud.retail.v2.Rating parseFrom(java.nio.ByteBuffer data) 277 throws com.google.protobuf.InvalidProtocolBufferException { 278 return PARSER.parseFrom(data); 279 } 280 parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)281 public static com.google.cloud.retail.v2.Rating parseFrom( 282 java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 283 throws com.google.protobuf.InvalidProtocolBufferException { 284 return PARSER.parseFrom(data, extensionRegistry); 285 } 286 parseFrom(com.google.protobuf.ByteString data)287 public static com.google.cloud.retail.v2.Rating parseFrom(com.google.protobuf.ByteString data) 288 throws com.google.protobuf.InvalidProtocolBufferException { 289 return PARSER.parseFrom(data); 290 } 291 parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)292 public static com.google.cloud.retail.v2.Rating parseFrom( 293 com.google.protobuf.ByteString data, 294 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 295 throws com.google.protobuf.InvalidProtocolBufferException { 296 return PARSER.parseFrom(data, extensionRegistry); 297 } 298 parseFrom(byte[] data)299 public static com.google.cloud.retail.v2.Rating parseFrom(byte[] data) 300 throws com.google.protobuf.InvalidProtocolBufferException { 301 return PARSER.parseFrom(data); 302 } 303 parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)304 public static com.google.cloud.retail.v2.Rating parseFrom( 305 byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 306 throws com.google.protobuf.InvalidProtocolBufferException { 307 return PARSER.parseFrom(data, extensionRegistry); 308 } 309 parseFrom(java.io.InputStream input)310 public static com.google.cloud.retail.v2.Rating parseFrom(java.io.InputStream input) 311 throws java.io.IOException { 312 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 313 } 314 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)315 public static com.google.cloud.retail.v2.Rating parseFrom( 316 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 317 throws java.io.IOException { 318 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 319 PARSER, input, extensionRegistry); 320 } 321 parseDelimitedFrom(java.io.InputStream input)322 public static com.google.cloud.retail.v2.Rating parseDelimitedFrom(java.io.InputStream input) 323 throws java.io.IOException { 324 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); 325 } 326 parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)327 public static com.google.cloud.retail.v2.Rating parseDelimitedFrom( 328 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 329 throws java.io.IOException { 330 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( 331 PARSER, input, extensionRegistry); 332 } 333 parseFrom( com.google.protobuf.CodedInputStream input)334 public static com.google.cloud.retail.v2.Rating parseFrom( 335 com.google.protobuf.CodedInputStream input) throws java.io.IOException { 336 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 337 } 338 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)339 public static com.google.cloud.retail.v2.Rating parseFrom( 340 com.google.protobuf.CodedInputStream input, 341 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 342 throws java.io.IOException { 343 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 344 PARSER, input, extensionRegistry); 345 } 346 347 @java.lang.Override newBuilderForType()348 public Builder newBuilderForType() { 349 return newBuilder(); 350 } 351 newBuilder()352 public static Builder newBuilder() { 353 return DEFAULT_INSTANCE.toBuilder(); 354 } 355 newBuilder(com.google.cloud.retail.v2.Rating prototype)356 public static Builder newBuilder(com.google.cloud.retail.v2.Rating prototype) { 357 return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 358 } 359 360 @java.lang.Override toBuilder()361 public Builder toBuilder() { 362 return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); 363 } 364 365 @java.lang.Override newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)366 protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 367 Builder builder = new Builder(parent); 368 return builder; 369 } 370 /** 371 * 372 * 373 * <pre> 374 * The rating of a [Product][google.cloud.retail.v2.Product]. 375 * </pre> 376 * 377 * Protobuf type {@code google.cloud.retail.v2.Rating} 378 */ 379 public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> 380 implements 381 // @@protoc_insertion_point(builder_implements:google.cloud.retail.v2.Rating) 382 com.google.cloud.retail.v2.RatingOrBuilder { getDescriptor()383 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 384 return com.google.cloud.retail.v2.CommonProto 385 .internal_static_google_cloud_retail_v2_Rating_descriptor; 386 } 387 388 @java.lang.Override 389 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()390 internalGetFieldAccessorTable() { 391 return com.google.cloud.retail.v2.CommonProto 392 .internal_static_google_cloud_retail_v2_Rating_fieldAccessorTable 393 .ensureFieldAccessorsInitialized( 394 com.google.cloud.retail.v2.Rating.class, 395 com.google.cloud.retail.v2.Rating.Builder.class); 396 } 397 398 // Construct using com.google.cloud.retail.v2.Rating.newBuilder() Builder()399 private Builder() {} 400 Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)401 private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 402 super(parent); 403 } 404 405 @java.lang.Override clear()406 public Builder clear() { 407 super.clear(); 408 bitField0_ = 0; 409 ratingCount_ = 0; 410 averageRating_ = 0F; 411 ratingHistogram_ = emptyIntList(); 412 return this; 413 } 414 415 @java.lang.Override getDescriptorForType()416 public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { 417 return com.google.cloud.retail.v2.CommonProto 418 .internal_static_google_cloud_retail_v2_Rating_descriptor; 419 } 420 421 @java.lang.Override getDefaultInstanceForType()422 public com.google.cloud.retail.v2.Rating getDefaultInstanceForType() { 423 return com.google.cloud.retail.v2.Rating.getDefaultInstance(); 424 } 425 426 @java.lang.Override build()427 public com.google.cloud.retail.v2.Rating build() { 428 com.google.cloud.retail.v2.Rating result = buildPartial(); 429 if (!result.isInitialized()) { 430 throw newUninitializedMessageException(result); 431 } 432 return result; 433 } 434 435 @java.lang.Override buildPartial()436 public com.google.cloud.retail.v2.Rating buildPartial() { 437 com.google.cloud.retail.v2.Rating result = new com.google.cloud.retail.v2.Rating(this); 438 buildPartialRepeatedFields(result); 439 if (bitField0_ != 0) { 440 buildPartial0(result); 441 } 442 onBuilt(); 443 return result; 444 } 445 buildPartialRepeatedFields(com.google.cloud.retail.v2.Rating result)446 private void buildPartialRepeatedFields(com.google.cloud.retail.v2.Rating result) { 447 if (((bitField0_ & 0x00000004) != 0)) { 448 ratingHistogram_.makeImmutable(); 449 bitField0_ = (bitField0_ & ~0x00000004); 450 } 451 result.ratingHistogram_ = ratingHistogram_; 452 } 453 buildPartial0(com.google.cloud.retail.v2.Rating result)454 private void buildPartial0(com.google.cloud.retail.v2.Rating result) { 455 int from_bitField0_ = bitField0_; 456 if (((from_bitField0_ & 0x00000001) != 0)) { 457 result.ratingCount_ = ratingCount_; 458 } 459 if (((from_bitField0_ & 0x00000002) != 0)) { 460 result.averageRating_ = averageRating_; 461 } 462 } 463 464 @java.lang.Override clone()465 public Builder clone() { 466 return super.clone(); 467 } 468 469 @java.lang.Override setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)470 public Builder setField( 471 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 472 return super.setField(field, value); 473 } 474 475 @java.lang.Override clearField(com.google.protobuf.Descriptors.FieldDescriptor field)476 public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { 477 return super.clearField(field); 478 } 479 480 @java.lang.Override clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)481 public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { 482 return super.clearOneof(oneof); 483 } 484 485 @java.lang.Override setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value)486 public Builder setRepeatedField( 487 com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { 488 return super.setRepeatedField(field, index, value); 489 } 490 491 @java.lang.Override addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)492 public Builder addRepeatedField( 493 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 494 return super.addRepeatedField(field, value); 495 } 496 497 @java.lang.Override mergeFrom(com.google.protobuf.Message other)498 public Builder mergeFrom(com.google.protobuf.Message other) { 499 if (other instanceof com.google.cloud.retail.v2.Rating) { 500 return mergeFrom((com.google.cloud.retail.v2.Rating) other); 501 } else { 502 super.mergeFrom(other); 503 return this; 504 } 505 } 506 mergeFrom(com.google.cloud.retail.v2.Rating other)507 public Builder mergeFrom(com.google.cloud.retail.v2.Rating other) { 508 if (other == com.google.cloud.retail.v2.Rating.getDefaultInstance()) return this; 509 if (other.getRatingCount() != 0) { 510 setRatingCount(other.getRatingCount()); 511 } 512 if (other.getAverageRating() != 0F) { 513 setAverageRating(other.getAverageRating()); 514 } 515 if (!other.ratingHistogram_.isEmpty()) { 516 if (ratingHistogram_.isEmpty()) { 517 ratingHistogram_ = other.ratingHistogram_; 518 bitField0_ = (bitField0_ & ~0x00000004); 519 } else { 520 ensureRatingHistogramIsMutable(); 521 ratingHistogram_.addAll(other.ratingHistogram_); 522 } 523 onChanged(); 524 } 525 this.mergeUnknownFields(other.getUnknownFields()); 526 onChanged(); 527 return this; 528 } 529 530 @java.lang.Override isInitialized()531 public final boolean isInitialized() { 532 return true; 533 } 534 535 @java.lang.Override mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)536 public Builder mergeFrom( 537 com.google.protobuf.CodedInputStream input, 538 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 539 throws java.io.IOException { 540 if (extensionRegistry == null) { 541 throw new java.lang.NullPointerException(); 542 } 543 try { 544 boolean done = false; 545 while (!done) { 546 int tag = input.readTag(); 547 switch (tag) { 548 case 0: 549 done = true; 550 break; 551 case 8: 552 { 553 ratingCount_ = input.readInt32(); 554 bitField0_ |= 0x00000001; 555 break; 556 } // case 8 557 case 21: 558 { 559 averageRating_ = input.readFloat(); 560 bitField0_ |= 0x00000002; 561 break; 562 } // case 21 563 case 24: 564 { 565 int v = input.readInt32(); 566 ensureRatingHistogramIsMutable(); 567 ratingHistogram_.addInt(v); 568 break; 569 } // case 24 570 case 26: 571 { 572 int length = input.readRawVarint32(); 573 int limit = input.pushLimit(length); 574 ensureRatingHistogramIsMutable(); 575 while (input.getBytesUntilLimit() > 0) { 576 ratingHistogram_.addInt(input.readInt32()); 577 } 578 input.popLimit(limit); 579 break; 580 } // case 26 581 default: 582 { 583 if (!super.parseUnknownField(input, extensionRegistry, tag)) { 584 done = true; // was an endgroup tag 585 } 586 break; 587 } // default: 588 } // switch (tag) 589 } // while (!done) 590 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 591 throw e.unwrapIOException(); 592 } finally { 593 onChanged(); 594 } // finally 595 return this; 596 } 597 598 private int bitField0_; 599 600 private int ratingCount_; 601 /** 602 * 603 * 604 * <pre> 605 * The total number of ratings. This value is independent of the value of 606 * [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. 607 * This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is 608 * returned. 609 * </pre> 610 * 611 * <code>int32 rating_count = 1;</code> 612 * 613 * @return The ratingCount. 614 */ 615 @java.lang.Override getRatingCount()616 public int getRatingCount() { 617 return ratingCount_; 618 } 619 /** 620 * 621 * 622 * <pre> 623 * The total number of ratings. This value is independent of the value of 624 * [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. 625 * This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is 626 * returned. 627 * </pre> 628 * 629 * <code>int32 rating_count = 1;</code> 630 * 631 * @param value The ratingCount to set. 632 * @return This builder for chaining. 633 */ setRatingCount(int value)634 public Builder setRatingCount(int value) { 635 636 ratingCount_ = value; 637 bitField0_ |= 0x00000001; 638 onChanged(); 639 return this; 640 } 641 /** 642 * 643 * 644 * <pre> 645 * The total number of ratings. This value is independent of the value of 646 * [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. 647 * This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is 648 * returned. 649 * </pre> 650 * 651 * <code>int32 rating_count = 1;</code> 652 * 653 * @return This builder for chaining. 654 */ clearRatingCount()655 public Builder clearRatingCount() { 656 bitField0_ = (bitField0_ & ~0x00000001); 657 ratingCount_ = 0; 658 onChanged(); 659 return this; 660 } 661 662 private float averageRating_; 663 /** 664 * 665 * 666 * <pre> 667 * The average rating of the [Product][google.cloud.retail.v2.Product]. 668 * The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is 669 * returned. 670 * </pre> 671 * 672 * <code>float average_rating = 2;</code> 673 * 674 * @return The averageRating. 675 */ 676 @java.lang.Override getAverageRating()677 public float getAverageRating() { 678 return averageRating_; 679 } 680 /** 681 * 682 * 683 * <pre> 684 * The average rating of the [Product][google.cloud.retail.v2.Product]. 685 * The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is 686 * returned. 687 * </pre> 688 * 689 * <code>float average_rating = 2;</code> 690 * 691 * @param value The averageRating to set. 692 * @return This builder for chaining. 693 */ setAverageRating(float value)694 public Builder setAverageRating(float value) { 695 696 averageRating_ = value; 697 bitField0_ |= 0x00000002; 698 onChanged(); 699 return this; 700 } 701 /** 702 * 703 * 704 * <pre> 705 * The average rating of the [Product][google.cloud.retail.v2.Product]. 706 * The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is 707 * returned. 708 * </pre> 709 * 710 * <code>float average_rating = 2;</code> 711 * 712 * @return This builder for chaining. 713 */ clearAverageRating()714 public Builder clearAverageRating() { 715 bitField0_ = (bitField0_ & ~0x00000002); 716 averageRating_ = 0F; 717 onChanged(); 718 return this; 719 } 720 721 private com.google.protobuf.Internal.IntList ratingHistogram_ = emptyIntList(); 722 ensureRatingHistogramIsMutable()723 private void ensureRatingHistogramIsMutable() { 724 if (!((bitField0_ & 0x00000004) != 0)) { 725 ratingHistogram_ = mutableCopy(ratingHistogram_); 726 bitField0_ |= 0x00000004; 727 } 728 } 729 /** 730 * 731 * 732 * <pre> 733 * List of rating counts per rating value (index = rating - 1). The list is 734 * empty if there is no rating. If the list is non-empty, its size is 735 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 736 * For example, [41, 14, 13, 47, 303]. It means that the 737 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 738 * ratings with 2 star, and so on. 739 * </pre> 740 * 741 * <code>repeated int32 rating_histogram = 3;</code> 742 * 743 * @return A list containing the ratingHistogram. 744 */ getRatingHistogramList()745 public java.util.List<java.lang.Integer> getRatingHistogramList() { 746 return ((bitField0_ & 0x00000004) != 0) 747 ? java.util.Collections.unmodifiableList(ratingHistogram_) 748 : ratingHistogram_; 749 } 750 /** 751 * 752 * 753 * <pre> 754 * List of rating counts per rating value (index = rating - 1). The list is 755 * empty if there is no rating. If the list is non-empty, its size is 756 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 757 * For example, [41, 14, 13, 47, 303]. It means that the 758 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 759 * ratings with 2 star, and so on. 760 * </pre> 761 * 762 * <code>repeated int32 rating_histogram = 3;</code> 763 * 764 * @return The count of ratingHistogram. 765 */ getRatingHistogramCount()766 public int getRatingHistogramCount() { 767 return ratingHistogram_.size(); 768 } 769 /** 770 * 771 * 772 * <pre> 773 * List of rating counts per rating value (index = rating - 1). The list is 774 * empty if there is no rating. If the list is non-empty, its size is 775 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 776 * For example, [41, 14, 13, 47, 303]. It means that the 777 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 778 * ratings with 2 star, and so on. 779 * </pre> 780 * 781 * <code>repeated int32 rating_histogram = 3;</code> 782 * 783 * @param index The index of the element to return. 784 * @return The ratingHistogram at the given index. 785 */ getRatingHistogram(int index)786 public int getRatingHistogram(int index) { 787 return ratingHistogram_.getInt(index); 788 } 789 /** 790 * 791 * 792 * <pre> 793 * List of rating counts per rating value (index = rating - 1). The list is 794 * empty if there is no rating. If the list is non-empty, its size is 795 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 796 * For example, [41, 14, 13, 47, 303]. It means that the 797 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 798 * ratings with 2 star, and so on. 799 * </pre> 800 * 801 * <code>repeated int32 rating_histogram = 3;</code> 802 * 803 * @param index The index to set the value at. 804 * @param value The ratingHistogram to set. 805 * @return This builder for chaining. 806 */ setRatingHistogram(int index, int value)807 public Builder setRatingHistogram(int index, int value) { 808 809 ensureRatingHistogramIsMutable(); 810 ratingHistogram_.setInt(index, value); 811 onChanged(); 812 return this; 813 } 814 /** 815 * 816 * 817 * <pre> 818 * List of rating counts per rating value (index = rating - 1). The list is 819 * empty if there is no rating. If the list is non-empty, its size is 820 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 821 * For example, [41, 14, 13, 47, 303]. It means that the 822 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 823 * ratings with 2 star, and so on. 824 * </pre> 825 * 826 * <code>repeated int32 rating_histogram = 3;</code> 827 * 828 * @param value The ratingHistogram to add. 829 * @return This builder for chaining. 830 */ addRatingHistogram(int value)831 public Builder addRatingHistogram(int value) { 832 833 ensureRatingHistogramIsMutable(); 834 ratingHistogram_.addInt(value); 835 onChanged(); 836 return this; 837 } 838 /** 839 * 840 * 841 * <pre> 842 * List of rating counts per rating value (index = rating - 1). The list is 843 * empty if there is no rating. If the list is non-empty, its size is 844 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 845 * For example, [41, 14, 13, 47, 303]. It means that the 846 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 847 * ratings with 2 star, and so on. 848 * </pre> 849 * 850 * <code>repeated int32 rating_histogram = 3;</code> 851 * 852 * @param values The ratingHistogram to add. 853 * @return This builder for chaining. 854 */ addAllRatingHistogram(java.lang.Iterable<? extends java.lang.Integer> values)855 public Builder addAllRatingHistogram(java.lang.Iterable<? extends java.lang.Integer> values) { 856 ensureRatingHistogramIsMutable(); 857 com.google.protobuf.AbstractMessageLite.Builder.addAll(values, ratingHistogram_); 858 onChanged(); 859 return this; 860 } 861 /** 862 * 863 * 864 * <pre> 865 * List of rating counts per rating value (index = rating - 1). The list is 866 * empty if there is no rating. If the list is non-empty, its size is 867 * always 5. Otherwise, an INVALID_ARGUMENT error is returned. 868 * For example, [41, 14, 13, 47, 303]. It means that the 869 * [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 870 * ratings with 2 star, and so on. 871 * </pre> 872 * 873 * <code>repeated int32 rating_histogram = 3;</code> 874 * 875 * @return This builder for chaining. 876 */ clearRatingHistogram()877 public Builder clearRatingHistogram() { 878 ratingHistogram_ = emptyIntList(); 879 bitField0_ = (bitField0_ & ~0x00000004); 880 onChanged(); 881 return this; 882 } 883 884 @java.lang.Override setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields)885 public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { 886 return super.setUnknownFields(unknownFields); 887 } 888 889 @java.lang.Override mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields)890 public final Builder mergeUnknownFields( 891 final com.google.protobuf.UnknownFieldSet unknownFields) { 892 return super.mergeUnknownFields(unknownFields); 893 } 894 895 // @@protoc_insertion_point(builder_scope:google.cloud.retail.v2.Rating) 896 } 897 898 // @@protoc_insertion_point(class_scope:google.cloud.retail.v2.Rating) 899 private static final com.google.cloud.retail.v2.Rating DEFAULT_INSTANCE; 900 901 static { 902 DEFAULT_INSTANCE = new com.google.cloud.retail.v2.Rating(); 903 } 904 getDefaultInstance()905 public static com.google.cloud.retail.v2.Rating getDefaultInstance() { 906 return DEFAULT_INSTANCE; 907 } 908 909 private static final com.google.protobuf.Parser<Rating> PARSER = 910 new com.google.protobuf.AbstractParser<Rating>() { 911 @java.lang.Override 912 public Rating parsePartialFrom( 913 com.google.protobuf.CodedInputStream input, 914 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 915 throws com.google.protobuf.InvalidProtocolBufferException { 916 Builder builder = newBuilder(); 917 try { 918 builder.mergeFrom(input, extensionRegistry); 919 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 920 throw e.setUnfinishedMessage(builder.buildPartial()); 921 } catch (com.google.protobuf.UninitializedMessageException e) { 922 throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); 923 } catch (java.io.IOException e) { 924 throw new com.google.protobuf.InvalidProtocolBufferException(e) 925 .setUnfinishedMessage(builder.buildPartial()); 926 } 927 return builder.buildPartial(); 928 } 929 }; 930 parser()931 public static com.google.protobuf.Parser<Rating> parser() { 932 return PARSER; 933 } 934 935 @java.lang.Override getParserForType()936 public com.google.protobuf.Parser<Rating> getParserForType() { 937 return PARSER; 938 } 939 940 @java.lang.Override getDefaultInstanceForType()941 public com.google.cloud.retail.v2.Rating getDefaultInstanceForType() { 942 return DEFAULT_INSTANCE; 943 } 944 } 945