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/language/v1/language_service.proto 18 19 package com.google.cloud.language.v1; 20 21 /** 22 * 23 * 24 * <pre> 25 * Represents a phrase in the text that is a known entity, such as 26 * a person, an organization, or location. The API associates information, such 27 * as salience and mentions, with entities. 28 * </pre> 29 * 30 * Protobuf type {@code google.cloud.language.v1.Entity} 31 */ 32 public final class Entity extends com.google.protobuf.GeneratedMessageV3 33 implements 34 // @@protoc_insertion_point(message_implements:google.cloud.language.v1.Entity) 35 EntityOrBuilder { 36 private static final long serialVersionUID = 0L; 37 // Use Entity.newBuilder() to construct. Entity(com.google.protobuf.GeneratedMessageV3.Builder<?> builder)38 private Entity(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { 39 super(builder); 40 } 41 Entity()42 private Entity() { 43 name_ = ""; 44 type_ = 0; 45 mentions_ = java.util.Collections.emptyList(); 46 } 47 48 @java.lang.Override 49 @SuppressWarnings({"unused"}) newInstance(UnusedPrivateParameter unused)50 protected java.lang.Object newInstance(UnusedPrivateParameter unused) { 51 return new Entity(); 52 } 53 54 @java.lang.Override getUnknownFields()55 public final com.google.protobuf.UnknownFieldSet getUnknownFields() { 56 return this.unknownFields; 57 } 58 getDescriptor()59 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 60 return com.google.cloud.language.v1.LanguageServiceProto 61 .internal_static_google_cloud_language_v1_Entity_descriptor; 62 } 63 64 @SuppressWarnings({"rawtypes"}) 65 @java.lang.Override internalGetMapField(int number)66 protected com.google.protobuf.MapField internalGetMapField(int number) { 67 switch (number) { 68 case 3: 69 return internalGetMetadata(); 70 default: 71 throw new RuntimeException("Invalid map field number: " + number); 72 } 73 } 74 75 @java.lang.Override 76 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()77 internalGetFieldAccessorTable() { 78 return com.google.cloud.language.v1.LanguageServiceProto 79 .internal_static_google_cloud_language_v1_Entity_fieldAccessorTable 80 .ensureFieldAccessorsInitialized( 81 com.google.cloud.language.v1.Entity.class, 82 com.google.cloud.language.v1.Entity.Builder.class); 83 } 84 85 /** 86 * 87 * 88 * <pre> 89 * The type of the entity. For most entity types, the associated metadata is a 90 * Wikipedia URL (`wikipedia_url`) and Knowledge Graph MID (`mid`). The table 91 * below lists the associated fields for entities that have different 92 * metadata. 93 * </pre> 94 * 95 * Protobuf enum {@code google.cloud.language.v1.Entity.Type} 96 */ 97 public enum Type implements com.google.protobuf.ProtocolMessageEnum { 98 /** 99 * 100 * 101 * <pre> 102 * Unknown 103 * </pre> 104 * 105 * <code>UNKNOWN = 0;</code> 106 */ 107 UNKNOWN(0), 108 /** 109 * 110 * 111 * <pre> 112 * Person 113 * </pre> 114 * 115 * <code>PERSON = 1;</code> 116 */ 117 PERSON(1), 118 /** 119 * 120 * 121 * <pre> 122 * Location 123 * </pre> 124 * 125 * <code>LOCATION = 2;</code> 126 */ 127 LOCATION(2), 128 /** 129 * 130 * 131 * <pre> 132 * Organization 133 * </pre> 134 * 135 * <code>ORGANIZATION = 3;</code> 136 */ 137 ORGANIZATION(3), 138 /** 139 * 140 * 141 * <pre> 142 * Event 143 * </pre> 144 * 145 * <code>EVENT = 4;</code> 146 */ 147 EVENT(4), 148 /** 149 * 150 * 151 * <pre> 152 * Artwork 153 * </pre> 154 * 155 * <code>WORK_OF_ART = 5;</code> 156 */ 157 WORK_OF_ART(5), 158 /** 159 * 160 * 161 * <pre> 162 * Consumer product 163 * </pre> 164 * 165 * <code>CONSUMER_GOOD = 6;</code> 166 */ 167 CONSUMER_GOOD(6), 168 /** 169 * 170 * 171 * <pre> 172 * Other types of entities 173 * </pre> 174 * 175 * <code>OTHER = 7;</code> 176 */ 177 OTHER(7), 178 /** 179 * 180 * 181 * <pre> 182 * Phone number 183 * The metadata lists the phone number, formatted according to local 184 * convention, plus whichever additional elements appear in the text: 185 * * `number` - the actual number, broken down into sections as per local 186 * convention 187 * * `national_prefix` - country code, if detected 188 * * `area_code` - region or area code, if detected 189 * * `extension` - phone extension (to be dialed after connection), if 190 * detected 191 * </pre> 192 * 193 * <code>PHONE_NUMBER = 9;</code> 194 */ 195 PHONE_NUMBER(9), 196 /** 197 * 198 * 199 * <pre> 200 * Address 201 * The metadata identifies the street number and locality plus whichever 202 * additional elements appear in the text: 203 * * `street_number` - street number 204 * * `locality` - city or town 205 * * `street_name` - street/route name, if detected 206 * * `postal_code` - postal code, if detected 207 * * `country` - country, if detected< 208 * * `broad_region` - administrative area, such as the state, if detected 209 * * `narrow_region` - smaller administrative area, such as county, if 210 * detected 211 * * `sublocality` - used in Asian addresses to demark a district within a 212 * city, if detected 213 * </pre> 214 * 215 * <code>ADDRESS = 10;</code> 216 */ 217 ADDRESS(10), 218 /** 219 * 220 * 221 * <pre> 222 * Date 223 * The metadata identifies the components of the date: 224 * * `year` - four digit year, if detected 225 * * `month` - two digit month number, if detected 226 * * `day` - two digit day number, if detected 227 * </pre> 228 * 229 * <code>DATE = 11;</code> 230 */ 231 DATE(11), 232 /** 233 * 234 * 235 * <pre> 236 * Number 237 * The metadata is the number itself. 238 * </pre> 239 * 240 * <code>NUMBER = 12;</code> 241 */ 242 NUMBER(12), 243 /** 244 * 245 * 246 * <pre> 247 * Price 248 * The metadata identifies the `value` and `currency`. 249 * </pre> 250 * 251 * <code>PRICE = 13;</code> 252 */ 253 PRICE(13), 254 UNRECOGNIZED(-1), 255 ; 256 257 /** 258 * 259 * 260 * <pre> 261 * Unknown 262 * </pre> 263 * 264 * <code>UNKNOWN = 0;</code> 265 */ 266 public static final int UNKNOWN_VALUE = 0; 267 /** 268 * 269 * 270 * <pre> 271 * Person 272 * </pre> 273 * 274 * <code>PERSON = 1;</code> 275 */ 276 public static final int PERSON_VALUE = 1; 277 /** 278 * 279 * 280 * <pre> 281 * Location 282 * </pre> 283 * 284 * <code>LOCATION = 2;</code> 285 */ 286 public static final int LOCATION_VALUE = 2; 287 /** 288 * 289 * 290 * <pre> 291 * Organization 292 * </pre> 293 * 294 * <code>ORGANIZATION = 3;</code> 295 */ 296 public static final int ORGANIZATION_VALUE = 3; 297 /** 298 * 299 * 300 * <pre> 301 * Event 302 * </pre> 303 * 304 * <code>EVENT = 4;</code> 305 */ 306 public static final int EVENT_VALUE = 4; 307 /** 308 * 309 * 310 * <pre> 311 * Artwork 312 * </pre> 313 * 314 * <code>WORK_OF_ART = 5;</code> 315 */ 316 public static final int WORK_OF_ART_VALUE = 5; 317 /** 318 * 319 * 320 * <pre> 321 * Consumer product 322 * </pre> 323 * 324 * <code>CONSUMER_GOOD = 6;</code> 325 */ 326 public static final int CONSUMER_GOOD_VALUE = 6; 327 /** 328 * 329 * 330 * <pre> 331 * Other types of entities 332 * </pre> 333 * 334 * <code>OTHER = 7;</code> 335 */ 336 public static final int OTHER_VALUE = 7; 337 /** 338 * 339 * 340 * <pre> 341 * Phone number 342 * The metadata lists the phone number, formatted according to local 343 * convention, plus whichever additional elements appear in the text: 344 * * `number` - the actual number, broken down into sections as per local 345 * convention 346 * * `national_prefix` - country code, if detected 347 * * `area_code` - region or area code, if detected 348 * * `extension` - phone extension (to be dialed after connection), if 349 * detected 350 * </pre> 351 * 352 * <code>PHONE_NUMBER = 9;</code> 353 */ 354 public static final int PHONE_NUMBER_VALUE = 9; 355 /** 356 * 357 * 358 * <pre> 359 * Address 360 * The metadata identifies the street number and locality plus whichever 361 * additional elements appear in the text: 362 * * `street_number` - street number 363 * * `locality` - city or town 364 * * `street_name` - street/route name, if detected 365 * * `postal_code` - postal code, if detected 366 * * `country` - country, if detected< 367 * * `broad_region` - administrative area, such as the state, if detected 368 * * `narrow_region` - smaller administrative area, such as county, if 369 * detected 370 * * `sublocality` - used in Asian addresses to demark a district within a 371 * city, if detected 372 * </pre> 373 * 374 * <code>ADDRESS = 10;</code> 375 */ 376 public static final int ADDRESS_VALUE = 10; 377 /** 378 * 379 * 380 * <pre> 381 * Date 382 * The metadata identifies the components of the date: 383 * * `year` - four digit year, if detected 384 * * `month` - two digit month number, if detected 385 * * `day` - two digit day number, if detected 386 * </pre> 387 * 388 * <code>DATE = 11;</code> 389 */ 390 public static final int DATE_VALUE = 11; 391 /** 392 * 393 * 394 * <pre> 395 * Number 396 * The metadata is the number itself. 397 * </pre> 398 * 399 * <code>NUMBER = 12;</code> 400 */ 401 public static final int NUMBER_VALUE = 12; 402 /** 403 * 404 * 405 * <pre> 406 * Price 407 * The metadata identifies the `value` and `currency`. 408 * </pre> 409 * 410 * <code>PRICE = 13;</code> 411 */ 412 public static final int PRICE_VALUE = 13; 413 getNumber()414 public final int getNumber() { 415 if (this == UNRECOGNIZED) { 416 throw new java.lang.IllegalArgumentException( 417 "Can't get the number of an unknown enum value."); 418 } 419 return value; 420 } 421 422 /** 423 * @param value The numeric wire value of the corresponding enum entry. 424 * @return The enum associated with the given numeric wire value. 425 * @deprecated Use {@link #forNumber(int)} instead. 426 */ 427 @java.lang.Deprecated valueOf(int value)428 public static Type valueOf(int value) { 429 return forNumber(value); 430 } 431 432 /** 433 * @param value The numeric wire value of the corresponding enum entry. 434 * @return The enum associated with the given numeric wire value. 435 */ forNumber(int value)436 public static Type forNumber(int value) { 437 switch (value) { 438 case 0: 439 return UNKNOWN; 440 case 1: 441 return PERSON; 442 case 2: 443 return LOCATION; 444 case 3: 445 return ORGANIZATION; 446 case 4: 447 return EVENT; 448 case 5: 449 return WORK_OF_ART; 450 case 6: 451 return CONSUMER_GOOD; 452 case 7: 453 return OTHER; 454 case 9: 455 return PHONE_NUMBER; 456 case 10: 457 return ADDRESS; 458 case 11: 459 return DATE; 460 case 12: 461 return NUMBER; 462 case 13: 463 return PRICE; 464 default: 465 return null; 466 } 467 } 468 internalGetValueMap()469 public static com.google.protobuf.Internal.EnumLiteMap<Type> internalGetValueMap() { 470 return internalValueMap; 471 } 472 473 private static final com.google.protobuf.Internal.EnumLiteMap<Type> internalValueMap = 474 new com.google.protobuf.Internal.EnumLiteMap<Type>() { 475 public Type findValueByNumber(int number) { 476 return Type.forNumber(number); 477 } 478 }; 479 getValueDescriptor()480 public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { 481 if (this == UNRECOGNIZED) { 482 throw new java.lang.IllegalStateException( 483 "Can't get the descriptor of an unrecognized enum value."); 484 } 485 return getDescriptor().getValues().get(ordinal()); 486 } 487 getDescriptorForType()488 public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { 489 return getDescriptor(); 490 } 491 getDescriptor()492 public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { 493 return com.google.cloud.language.v1.Entity.getDescriptor().getEnumTypes().get(0); 494 } 495 496 private static final Type[] VALUES = values(); 497 valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc)498 public static Type valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { 499 if (desc.getType() != getDescriptor()) { 500 throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); 501 } 502 if (desc.getIndex() == -1) { 503 return UNRECOGNIZED; 504 } 505 return VALUES[desc.getIndex()]; 506 } 507 508 private final int value; 509 Type(int value)510 private Type(int value) { 511 this.value = value; 512 } 513 514 // @@protoc_insertion_point(enum_scope:google.cloud.language.v1.Entity.Type) 515 } 516 517 public static final int NAME_FIELD_NUMBER = 1; 518 519 @SuppressWarnings("serial") 520 private volatile java.lang.Object name_ = ""; 521 /** 522 * 523 * 524 * <pre> 525 * The representative name for the entity. 526 * </pre> 527 * 528 * <code>string name = 1;</code> 529 * 530 * @return The name. 531 */ 532 @java.lang.Override getName()533 public java.lang.String getName() { 534 java.lang.Object ref = name_; 535 if (ref instanceof java.lang.String) { 536 return (java.lang.String) ref; 537 } else { 538 com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; 539 java.lang.String s = bs.toStringUtf8(); 540 name_ = s; 541 return s; 542 } 543 } 544 /** 545 * 546 * 547 * <pre> 548 * The representative name for the entity. 549 * </pre> 550 * 551 * <code>string name = 1;</code> 552 * 553 * @return The bytes for name. 554 */ 555 @java.lang.Override getNameBytes()556 public com.google.protobuf.ByteString getNameBytes() { 557 java.lang.Object ref = name_; 558 if (ref instanceof java.lang.String) { 559 com.google.protobuf.ByteString b = 560 com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); 561 name_ = b; 562 return b; 563 } else { 564 return (com.google.protobuf.ByteString) ref; 565 } 566 } 567 568 public static final int TYPE_FIELD_NUMBER = 2; 569 private int type_ = 0; 570 /** 571 * 572 * 573 * <pre> 574 * The entity type. 575 * </pre> 576 * 577 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 578 * 579 * @return The enum numeric value on the wire for type. 580 */ 581 @java.lang.Override getTypeValue()582 public int getTypeValue() { 583 return type_; 584 } 585 /** 586 * 587 * 588 * <pre> 589 * The entity type. 590 * </pre> 591 * 592 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 593 * 594 * @return The type. 595 */ 596 @java.lang.Override getType()597 public com.google.cloud.language.v1.Entity.Type getType() { 598 com.google.cloud.language.v1.Entity.Type result = 599 com.google.cloud.language.v1.Entity.Type.forNumber(type_); 600 return result == null ? com.google.cloud.language.v1.Entity.Type.UNRECOGNIZED : result; 601 } 602 603 public static final int METADATA_FIELD_NUMBER = 3; 604 605 private static final class MetadataDefaultEntryHolder { 606 static final com.google.protobuf.MapEntry<java.lang.String, java.lang.String> defaultEntry = 607 com.google.protobuf.MapEntry.<java.lang.String, java.lang.String>newDefaultInstance( 608 com.google.cloud.language.v1.LanguageServiceProto 609 .internal_static_google_cloud_language_v1_Entity_MetadataEntry_descriptor, 610 com.google.protobuf.WireFormat.FieldType.STRING, 611 "", 612 com.google.protobuf.WireFormat.FieldType.STRING, 613 ""); 614 } 615 616 @SuppressWarnings("serial") 617 private com.google.protobuf.MapField<java.lang.String, java.lang.String> metadata_; 618 internalGetMetadata()619 private com.google.protobuf.MapField<java.lang.String, java.lang.String> internalGetMetadata() { 620 if (metadata_ == null) { 621 return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry); 622 } 623 return metadata_; 624 } 625 getMetadataCount()626 public int getMetadataCount() { 627 return internalGetMetadata().getMap().size(); 628 } 629 /** 630 * 631 * 632 * <pre> 633 * Metadata associated with the entity. 634 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 635 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 636 * associated with other entity types, see the Type table below. 637 * </pre> 638 * 639 * <code>map<string, string> metadata = 3;</code> 640 */ 641 @java.lang.Override containsMetadata(java.lang.String key)642 public boolean containsMetadata(java.lang.String key) { 643 if (key == null) { 644 throw new NullPointerException("map key"); 645 } 646 return internalGetMetadata().getMap().containsKey(key); 647 } 648 /** Use {@link #getMetadataMap()} instead. */ 649 @java.lang.Override 650 @java.lang.Deprecated getMetadata()651 public java.util.Map<java.lang.String, java.lang.String> getMetadata() { 652 return getMetadataMap(); 653 } 654 /** 655 * 656 * 657 * <pre> 658 * Metadata associated with the entity. 659 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 660 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 661 * associated with other entity types, see the Type table below. 662 * </pre> 663 * 664 * <code>map<string, string> metadata = 3;</code> 665 */ 666 @java.lang.Override getMetadataMap()667 public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() { 668 return internalGetMetadata().getMap(); 669 } 670 /** 671 * 672 * 673 * <pre> 674 * Metadata associated with the entity. 675 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 676 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 677 * associated with other entity types, see the Type table below. 678 * </pre> 679 * 680 * <code>map<string, string> metadata = 3;</code> 681 */ 682 @java.lang.Override getMetadataOrDefault( java.lang.String key, java.lang.String defaultValue)683 public /* nullable */ java.lang.String getMetadataOrDefault( 684 java.lang.String key, 685 /* nullable */ 686 java.lang.String defaultValue) { 687 if (key == null) { 688 throw new NullPointerException("map key"); 689 } 690 java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap(); 691 return map.containsKey(key) ? map.get(key) : defaultValue; 692 } 693 /** 694 * 695 * 696 * <pre> 697 * Metadata associated with the entity. 698 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 699 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 700 * associated with other entity types, see the Type table below. 701 * </pre> 702 * 703 * <code>map<string, string> metadata = 3;</code> 704 */ 705 @java.lang.Override getMetadataOrThrow(java.lang.String key)706 public java.lang.String getMetadataOrThrow(java.lang.String key) { 707 if (key == null) { 708 throw new NullPointerException("map key"); 709 } 710 java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap(); 711 if (!map.containsKey(key)) { 712 throw new java.lang.IllegalArgumentException(); 713 } 714 return map.get(key); 715 } 716 717 public static final int SALIENCE_FIELD_NUMBER = 4; 718 private float salience_ = 0F; 719 /** 720 * 721 * 722 * <pre> 723 * The salience score associated with the entity in the [0, 1.0] range. 724 * The salience score for an entity provides information about the 725 * importance or centrality of that entity to the entire document text. 726 * Scores closer to 0 are less salient, while scores closer to 1.0 are highly 727 * salient. 728 * </pre> 729 * 730 * <code>float salience = 4;</code> 731 * 732 * @return The salience. 733 */ 734 @java.lang.Override getSalience()735 public float getSalience() { 736 return salience_; 737 } 738 739 public static final int MENTIONS_FIELD_NUMBER = 5; 740 741 @SuppressWarnings("serial") 742 private java.util.List<com.google.cloud.language.v1.EntityMention> mentions_; 743 /** 744 * 745 * 746 * <pre> 747 * The mentions of this entity in the input document. The API currently 748 * supports proper noun mentions. 749 * </pre> 750 * 751 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 752 */ 753 @java.lang.Override getMentionsList()754 public java.util.List<com.google.cloud.language.v1.EntityMention> getMentionsList() { 755 return mentions_; 756 } 757 /** 758 * 759 * 760 * <pre> 761 * The mentions of this entity in the input document. The API currently 762 * supports proper noun mentions. 763 * </pre> 764 * 765 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 766 */ 767 @java.lang.Override 768 public java.util.List<? extends com.google.cloud.language.v1.EntityMentionOrBuilder> getMentionsOrBuilderList()769 getMentionsOrBuilderList() { 770 return mentions_; 771 } 772 /** 773 * 774 * 775 * <pre> 776 * The mentions of this entity in the input document. The API currently 777 * supports proper noun mentions. 778 * </pre> 779 * 780 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 781 */ 782 @java.lang.Override getMentionsCount()783 public int getMentionsCount() { 784 return mentions_.size(); 785 } 786 /** 787 * 788 * 789 * <pre> 790 * The mentions of this entity in the input document. The API currently 791 * supports proper noun mentions. 792 * </pre> 793 * 794 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 795 */ 796 @java.lang.Override getMentions(int index)797 public com.google.cloud.language.v1.EntityMention getMentions(int index) { 798 return mentions_.get(index); 799 } 800 /** 801 * 802 * 803 * <pre> 804 * The mentions of this entity in the input document. The API currently 805 * supports proper noun mentions. 806 * </pre> 807 * 808 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 809 */ 810 @java.lang.Override getMentionsOrBuilder(int index)811 public com.google.cloud.language.v1.EntityMentionOrBuilder getMentionsOrBuilder(int index) { 812 return mentions_.get(index); 813 } 814 815 public static final int SENTIMENT_FIELD_NUMBER = 6; 816 private com.google.cloud.language.v1.Sentiment sentiment_; 817 /** 818 * 819 * 820 * <pre> 821 * For calls to [AnalyzeEntitySentiment][] or if 822 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 823 * is set to true, this field will contain the aggregate sentiment expressed 824 * for this entity in the provided document. 825 * </pre> 826 * 827 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 828 * 829 * @return Whether the sentiment field is set. 830 */ 831 @java.lang.Override hasSentiment()832 public boolean hasSentiment() { 833 return sentiment_ != null; 834 } 835 /** 836 * 837 * 838 * <pre> 839 * For calls to [AnalyzeEntitySentiment][] or if 840 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 841 * is set to true, this field will contain the aggregate sentiment expressed 842 * for this entity in the provided document. 843 * </pre> 844 * 845 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 846 * 847 * @return The sentiment. 848 */ 849 @java.lang.Override getSentiment()850 public com.google.cloud.language.v1.Sentiment getSentiment() { 851 return sentiment_ == null 852 ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() 853 : sentiment_; 854 } 855 /** 856 * 857 * 858 * <pre> 859 * For calls to [AnalyzeEntitySentiment][] or if 860 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 861 * is set to true, this field will contain the aggregate sentiment expressed 862 * for this entity in the provided document. 863 * </pre> 864 * 865 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 866 */ 867 @java.lang.Override getSentimentOrBuilder()868 public com.google.cloud.language.v1.SentimentOrBuilder getSentimentOrBuilder() { 869 return sentiment_ == null 870 ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() 871 : sentiment_; 872 } 873 874 private byte memoizedIsInitialized = -1; 875 876 @java.lang.Override isInitialized()877 public final boolean isInitialized() { 878 byte isInitialized = memoizedIsInitialized; 879 if (isInitialized == 1) return true; 880 if (isInitialized == 0) return false; 881 882 memoizedIsInitialized = 1; 883 return true; 884 } 885 886 @java.lang.Override writeTo(com.google.protobuf.CodedOutputStream output)887 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { 888 if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { 889 com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); 890 } 891 if (type_ != com.google.cloud.language.v1.Entity.Type.UNKNOWN.getNumber()) { 892 output.writeEnum(2, type_); 893 } 894 com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( 895 output, internalGetMetadata(), MetadataDefaultEntryHolder.defaultEntry, 3); 896 if (java.lang.Float.floatToRawIntBits(salience_) != 0) { 897 output.writeFloat(4, salience_); 898 } 899 for (int i = 0; i < mentions_.size(); i++) { 900 output.writeMessage(5, mentions_.get(i)); 901 } 902 if (sentiment_ != null) { 903 output.writeMessage(6, getSentiment()); 904 } 905 getUnknownFields().writeTo(output); 906 } 907 908 @java.lang.Override getSerializedSize()909 public int getSerializedSize() { 910 int size = memoizedSize; 911 if (size != -1) return size; 912 913 size = 0; 914 if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { 915 size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); 916 } 917 if (type_ != com.google.cloud.language.v1.Entity.Type.UNKNOWN.getNumber()) { 918 size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, type_); 919 } 920 for (java.util.Map.Entry<java.lang.String, java.lang.String> entry : 921 internalGetMetadata().getMap().entrySet()) { 922 com.google.protobuf.MapEntry<java.lang.String, java.lang.String> metadata__ = 923 MetadataDefaultEntryHolder.defaultEntry 924 .newBuilderForType() 925 .setKey(entry.getKey()) 926 .setValue(entry.getValue()) 927 .build(); 928 size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, metadata__); 929 } 930 if (java.lang.Float.floatToRawIntBits(salience_) != 0) { 931 size += com.google.protobuf.CodedOutputStream.computeFloatSize(4, salience_); 932 } 933 for (int i = 0; i < mentions_.size(); i++) { 934 size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, mentions_.get(i)); 935 } 936 if (sentiment_ != null) { 937 size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getSentiment()); 938 } 939 size += getUnknownFields().getSerializedSize(); 940 memoizedSize = size; 941 return size; 942 } 943 944 @java.lang.Override equals(final java.lang.Object obj)945 public boolean equals(final java.lang.Object obj) { 946 if (obj == this) { 947 return true; 948 } 949 if (!(obj instanceof com.google.cloud.language.v1.Entity)) { 950 return super.equals(obj); 951 } 952 com.google.cloud.language.v1.Entity other = (com.google.cloud.language.v1.Entity) obj; 953 954 if (!getName().equals(other.getName())) return false; 955 if (type_ != other.type_) return false; 956 if (!internalGetMetadata().equals(other.internalGetMetadata())) return false; 957 if (java.lang.Float.floatToIntBits(getSalience()) 958 != java.lang.Float.floatToIntBits(other.getSalience())) return false; 959 if (!getMentionsList().equals(other.getMentionsList())) return false; 960 if (hasSentiment() != other.hasSentiment()) return false; 961 if (hasSentiment()) { 962 if (!getSentiment().equals(other.getSentiment())) return false; 963 } 964 if (!getUnknownFields().equals(other.getUnknownFields())) return false; 965 return true; 966 } 967 968 @java.lang.Override hashCode()969 public int hashCode() { 970 if (memoizedHashCode != 0) { 971 return memoizedHashCode; 972 } 973 int hash = 41; 974 hash = (19 * hash) + getDescriptor().hashCode(); 975 hash = (37 * hash) + NAME_FIELD_NUMBER; 976 hash = (53 * hash) + getName().hashCode(); 977 hash = (37 * hash) + TYPE_FIELD_NUMBER; 978 hash = (53 * hash) + type_; 979 if (!internalGetMetadata().getMap().isEmpty()) { 980 hash = (37 * hash) + METADATA_FIELD_NUMBER; 981 hash = (53 * hash) + internalGetMetadata().hashCode(); 982 } 983 hash = (37 * hash) + SALIENCE_FIELD_NUMBER; 984 hash = (53 * hash) + java.lang.Float.floatToIntBits(getSalience()); 985 if (getMentionsCount() > 0) { 986 hash = (37 * hash) + MENTIONS_FIELD_NUMBER; 987 hash = (53 * hash) + getMentionsList().hashCode(); 988 } 989 if (hasSentiment()) { 990 hash = (37 * hash) + SENTIMENT_FIELD_NUMBER; 991 hash = (53 * hash) + getSentiment().hashCode(); 992 } 993 hash = (29 * hash) + getUnknownFields().hashCode(); 994 memoizedHashCode = hash; 995 return hash; 996 } 997 parseFrom(java.nio.ByteBuffer data)998 public static com.google.cloud.language.v1.Entity parseFrom(java.nio.ByteBuffer data) 999 throws com.google.protobuf.InvalidProtocolBufferException { 1000 return PARSER.parseFrom(data); 1001 } 1002 parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1003 public static com.google.cloud.language.v1.Entity parseFrom( 1004 java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1005 throws com.google.protobuf.InvalidProtocolBufferException { 1006 return PARSER.parseFrom(data, extensionRegistry); 1007 } 1008 parseFrom(com.google.protobuf.ByteString data)1009 public static com.google.cloud.language.v1.Entity parseFrom(com.google.protobuf.ByteString data) 1010 throws com.google.protobuf.InvalidProtocolBufferException { 1011 return PARSER.parseFrom(data); 1012 } 1013 parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1014 public static com.google.cloud.language.v1.Entity parseFrom( 1015 com.google.protobuf.ByteString data, 1016 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1017 throws com.google.protobuf.InvalidProtocolBufferException { 1018 return PARSER.parseFrom(data, extensionRegistry); 1019 } 1020 parseFrom(byte[] data)1021 public static com.google.cloud.language.v1.Entity parseFrom(byte[] data) 1022 throws com.google.protobuf.InvalidProtocolBufferException { 1023 return PARSER.parseFrom(data); 1024 } 1025 parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1026 public static com.google.cloud.language.v1.Entity parseFrom( 1027 byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1028 throws com.google.protobuf.InvalidProtocolBufferException { 1029 return PARSER.parseFrom(data, extensionRegistry); 1030 } 1031 parseFrom(java.io.InputStream input)1032 public static com.google.cloud.language.v1.Entity parseFrom(java.io.InputStream input) 1033 throws java.io.IOException { 1034 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 1035 } 1036 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1037 public static com.google.cloud.language.v1.Entity parseFrom( 1038 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1039 throws java.io.IOException { 1040 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 1041 PARSER, input, extensionRegistry); 1042 } 1043 parseDelimitedFrom(java.io.InputStream input)1044 public static com.google.cloud.language.v1.Entity parseDelimitedFrom(java.io.InputStream input) 1045 throws java.io.IOException { 1046 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); 1047 } 1048 parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1049 public static com.google.cloud.language.v1.Entity parseDelimitedFrom( 1050 java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1051 throws java.io.IOException { 1052 return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( 1053 PARSER, input, extensionRegistry); 1054 } 1055 parseFrom( com.google.protobuf.CodedInputStream input)1056 public static com.google.cloud.language.v1.Entity parseFrom( 1057 com.google.protobuf.CodedInputStream input) throws java.io.IOException { 1058 return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); 1059 } 1060 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1061 public static com.google.cloud.language.v1.Entity parseFrom( 1062 com.google.protobuf.CodedInputStream input, 1063 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1064 throws java.io.IOException { 1065 return com.google.protobuf.GeneratedMessageV3.parseWithIOException( 1066 PARSER, input, extensionRegistry); 1067 } 1068 1069 @java.lang.Override newBuilderForType()1070 public Builder newBuilderForType() { 1071 return newBuilder(); 1072 } 1073 newBuilder()1074 public static Builder newBuilder() { 1075 return DEFAULT_INSTANCE.toBuilder(); 1076 } 1077 newBuilder(com.google.cloud.language.v1.Entity prototype)1078 public static Builder newBuilder(com.google.cloud.language.v1.Entity prototype) { 1079 return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 1080 } 1081 1082 @java.lang.Override toBuilder()1083 public Builder toBuilder() { 1084 return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); 1085 } 1086 1087 @java.lang.Override newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)1088 protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1089 Builder builder = new Builder(parent); 1090 return builder; 1091 } 1092 /** 1093 * 1094 * 1095 * <pre> 1096 * Represents a phrase in the text that is a known entity, such as 1097 * a person, an organization, or location. The API associates information, such 1098 * as salience and mentions, with entities. 1099 * </pre> 1100 * 1101 * Protobuf type {@code google.cloud.language.v1.Entity} 1102 */ 1103 public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> 1104 implements 1105 // @@protoc_insertion_point(builder_implements:google.cloud.language.v1.Entity) 1106 com.google.cloud.language.v1.EntityOrBuilder { getDescriptor()1107 public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { 1108 return com.google.cloud.language.v1.LanguageServiceProto 1109 .internal_static_google_cloud_language_v1_Entity_descriptor; 1110 } 1111 1112 @SuppressWarnings({"rawtypes"}) internalGetMapField(int number)1113 protected com.google.protobuf.MapField internalGetMapField(int number) { 1114 switch (number) { 1115 case 3: 1116 return internalGetMetadata(); 1117 default: 1118 throw new RuntimeException("Invalid map field number: " + number); 1119 } 1120 } 1121 1122 @SuppressWarnings({"rawtypes"}) internalGetMutableMapField(int number)1123 protected com.google.protobuf.MapField internalGetMutableMapField(int number) { 1124 switch (number) { 1125 case 3: 1126 return internalGetMutableMetadata(); 1127 default: 1128 throw new RuntimeException("Invalid map field number: " + number); 1129 } 1130 } 1131 1132 @java.lang.Override 1133 protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()1134 internalGetFieldAccessorTable() { 1135 return com.google.cloud.language.v1.LanguageServiceProto 1136 .internal_static_google_cloud_language_v1_Entity_fieldAccessorTable 1137 .ensureFieldAccessorsInitialized( 1138 com.google.cloud.language.v1.Entity.class, 1139 com.google.cloud.language.v1.Entity.Builder.class); 1140 } 1141 1142 // Construct using com.google.cloud.language.v1.Entity.newBuilder() Builder()1143 private Builder() {} 1144 Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)1145 private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1146 super(parent); 1147 } 1148 1149 @java.lang.Override clear()1150 public Builder clear() { 1151 super.clear(); 1152 bitField0_ = 0; 1153 name_ = ""; 1154 type_ = 0; 1155 internalGetMutableMetadata().clear(); 1156 salience_ = 0F; 1157 if (mentionsBuilder_ == null) { 1158 mentions_ = java.util.Collections.emptyList(); 1159 } else { 1160 mentions_ = null; 1161 mentionsBuilder_.clear(); 1162 } 1163 bitField0_ = (bitField0_ & ~0x00000010); 1164 sentiment_ = null; 1165 if (sentimentBuilder_ != null) { 1166 sentimentBuilder_.dispose(); 1167 sentimentBuilder_ = null; 1168 } 1169 return this; 1170 } 1171 1172 @java.lang.Override getDescriptorForType()1173 public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { 1174 return com.google.cloud.language.v1.LanguageServiceProto 1175 .internal_static_google_cloud_language_v1_Entity_descriptor; 1176 } 1177 1178 @java.lang.Override getDefaultInstanceForType()1179 public com.google.cloud.language.v1.Entity getDefaultInstanceForType() { 1180 return com.google.cloud.language.v1.Entity.getDefaultInstance(); 1181 } 1182 1183 @java.lang.Override build()1184 public com.google.cloud.language.v1.Entity build() { 1185 com.google.cloud.language.v1.Entity result = buildPartial(); 1186 if (!result.isInitialized()) { 1187 throw newUninitializedMessageException(result); 1188 } 1189 return result; 1190 } 1191 1192 @java.lang.Override buildPartial()1193 public com.google.cloud.language.v1.Entity buildPartial() { 1194 com.google.cloud.language.v1.Entity result = new com.google.cloud.language.v1.Entity(this); 1195 buildPartialRepeatedFields(result); 1196 if (bitField0_ != 0) { 1197 buildPartial0(result); 1198 } 1199 onBuilt(); 1200 return result; 1201 } 1202 buildPartialRepeatedFields(com.google.cloud.language.v1.Entity result)1203 private void buildPartialRepeatedFields(com.google.cloud.language.v1.Entity result) { 1204 if (mentionsBuilder_ == null) { 1205 if (((bitField0_ & 0x00000010) != 0)) { 1206 mentions_ = java.util.Collections.unmodifiableList(mentions_); 1207 bitField0_ = (bitField0_ & ~0x00000010); 1208 } 1209 result.mentions_ = mentions_; 1210 } else { 1211 result.mentions_ = mentionsBuilder_.build(); 1212 } 1213 } 1214 buildPartial0(com.google.cloud.language.v1.Entity result)1215 private void buildPartial0(com.google.cloud.language.v1.Entity result) { 1216 int from_bitField0_ = bitField0_; 1217 if (((from_bitField0_ & 0x00000001) != 0)) { 1218 result.name_ = name_; 1219 } 1220 if (((from_bitField0_ & 0x00000002) != 0)) { 1221 result.type_ = type_; 1222 } 1223 if (((from_bitField0_ & 0x00000004) != 0)) { 1224 result.metadata_ = internalGetMetadata(); 1225 result.metadata_.makeImmutable(); 1226 } 1227 if (((from_bitField0_ & 0x00000008) != 0)) { 1228 result.salience_ = salience_; 1229 } 1230 if (((from_bitField0_ & 0x00000020) != 0)) { 1231 result.sentiment_ = sentimentBuilder_ == null ? sentiment_ : sentimentBuilder_.build(); 1232 } 1233 } 1234 1235 @java.lang.Override clone()1236 public Builder clone() { 1237 return super.clone(); 1238 } 1239 1240 @java.lang.Override setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)1241 public Builder setField( 1242 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 1243 return super.setField(field, value); 1244 } 1245 1246 @java.lang.Override clearField(com.google.protobuf.Descriptors.FieldDescriptor field)1247 public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { 1248 return super.clearField(field); 1249 } 1250 1251 @java.lang.Override clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof)1252 public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { 1253 return super.clearOneof(oneof); 1254 } 1255 1256 @java.lang.Override setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value)1257 public Builder setRepeatedField( 1258 com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { 1259 return super.setRepeatedField(field, index, value); 1260 } 1261 1262 @java.lang.Override addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value)1263 public Builder addRepeatedField( 1264 com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { 1265 return super.addRepeatedField(field, value); 1266 } 1267 1268 @java.lang.Override mergeFrom(com.google.protobuf.Message other)1269 public Builder mergeFrom(com.google.protobuf.Message other) { 1270 if (other instanceof com.google.cloud.language.v1.Entity) { 1271 return mergeFrom((com.google.cloud.language.v1.Entity) other); 1272 } else { 1273 super.mergeFrom(other); 1274 return this; 1275 } 1276 } 1277 mergeFrom(com.google.cloud.language.v1.Entity other)1278 public Builder mergeFrom(com.google.cloud.language.v1.Entity other) { 1279 if (other == com.google.cloud.language.v1.Entity.getDefaultInstance()) return this; 1280 if (!other.getName().isEmpty()) { 1281 name_ = other.name_; 1282 bitField0_ |= 0x00000001; 1283 onChanged(); 1284 } 1285 if (other.type_ != 0) { 1286 setTypeValue(other.getTypeValue()); 1287 } 1288 internalGetMutableMetadata().mergeFrom(other.internalGetMetadata()); 1289 bitField0_ |= 0x00000004; 1290 if (other.getSalience() != 0F) { 1291 setSalience(other.getSalience()); 1292 } 1293 if (mentionsBuilder_ == null) { 1294 if (!other.mentions_.isEmpty()) { 1295 if (mentions_.isEmpty()) { 1296 mentions_ = other.mentions_; 1297 bitField0_ = (bitField0_ & ~0x00000010); 1298 } else { 1299 ensureMentionsIsMutable(); 1300 mentions_.addAll(other.mentions_); 1301 } 1302 onChanged(); 1303 } 1304 } else { 1305 if (!other.mentions_.isEmpty()) { 1306 if (mentionsBuilder_.isEmpty()) { 1307 mentionsBuilder_.dispose(); 1308 mentionsBuilder_ = null; 1309 mentions_ = other.mentions_; 1310 bitField0_ = (bitField0_ & ~0x00000010); 1311 mentionsBuilder_ = 1312 com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders 1313 ? getMentionsFieldBuilder() 1314 : null; 1315 } else { 1316 mentionsBuilder_.addAllMessages(other.mentions_); 1317 } 1318 } 1319 } 1320 if (other.hasSentiment()) { 1321 mergeSentiment(other.getSentiment()); 1322 } 1323 this.mergeUnknownFields(other.getUnknownFields()); 1324 onChanged(); 1325 return this; 1326 } 1327 1328 @java.lang.Override isInitialized()1329 public final boolean isInitialized() { 1330 return true; 1331 } 1332 1333 @java.lang.Override mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)1334 public Builder mergeFrom( 1335 com.google.protobuf.CodedInputStream input, 1336 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1337 throws java.io.IOException { 1338 if (extensionRegistry == null) { 1339 throw new java.lang.NullPointerException(); 1340 } 1341 try { 1342 boolean done = false; 1343 while (!done) { 1344 int tag = input.readTag(); 1345 switch (tag) { 1346 case 0: 1347 done = true; 1348 break; 1349 case 10: 1350 { 1351 name_ = input.readStringRequireUtf8(); 1352 bitField0_ |= 0x00000001; 1353 break; 1354 } // case 10 1355 case 16: 1356 { 1357 type_ = input.readEnum(); 1358 bitField0_ |= 0x00000002; 1359 break; 1360 } // case 16 1361 case 26: 1362 { 1363 com.google.protobuf.MapEntry<java.lang.String, java.lang.String> metadata__ = 1364 input.readMessage( 1365 MetadataDefaultEntryHolder.defaultEntry.getParserForType(), 1366 extensionRegistry); 1367 internalGetMutableMetadata() 1368 .getMutableMap() 1369 .put(metadata__.getKey(), metadata__.getValue()); 1370 bitField0_ |= 0x00000004; 1371 break; 1372 } // case 26 1373 case 37: 1374 { 1375 salience_ = input.readFloat(); 1376 bitField0_ |= 0x00000008; 1377 break; 1378 } // case 37 1379 case 42: 1380 { 1381 com.google.cloud.language.v1.EntityMention m = 1382 input.readMessage( 1383 com.google.cloud.language.v1.EntityMention.parser(), extensionRegistry); 1384 if (mentionsBuilder_ == null) { 1385 ensureMentionsIsMutable(); 1386 mentions_.add(m); 1387 } else { 1388 mentionsBuilder_.addMessage(m); 1389 } 1390 break; 1391 } // case 42 1392 case 50: 1393 { 1394 input.readMessage(getSentimentFieldBuilder().getBuilder(), extensionRegistry); 1395 bitField0_ |= 0x00000020; 1396 break; 1397 } // case 50 1398 default: 1399 { 1400 if (!super.parseUnknownField(input, extensionRegistry, tag)) { 1401 done = true; // was an endgroup tag 1402 } 1403 break; 1404 } // default: 1405 } // switch (tag) 1406 } // while (!done) 1407 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1408 throw e.unwrapIOException(); 1409 } finally { 1410 onChanged(); 1411 } // finally 1412 return this; 1413 } 1414 1415 private int bitField0_; 1416 1417 private java.lang.Object name_ = ""; 1418 /** 1419 * 1420 * 1421 * <pre> 1422 * The representative name for the entity. 1423 * </pre> 1424 * 1425 * <code>string name = 1;</code> 1426 * 1427 * @return The name. 1428 */ getName()1429 public java.lang.String getName() { 1430 java.lang.Object ref = name_; 1431 if (!(ref instanceof java.lang.String)) { 1432 com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; 1433 java.lang.String s = bs.toStringUtf8(); 1434 name_ = s; 1435 return s; 1436 } else { 1437 return (java.lang.String) ref; 1438 } 1439 } 1440 /** 1441 * 1442 * 1443 * <pre> 1444 * The representative name for the entity. 1445 * </pre> 1446 * 1447 * <code>string name = 1;</code> 1448 * 1449 * @return The bytes for name. 1450 */ getNameBytes()1451 public com.google.protobuf.ByteString getNameBytes() { 1452 java.lang.Object ref = name_; 1453 if (ref instanceof String) { 1454 com.google.protobuf.ByteString b = 1455 com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); 1456 name_ = b; 1457 return b; 1458 } else { 1459 return (com.google.protobuf.ByteString) ref; 1460 } 1461 } 1462 /** 1463 * 1464 * 1465 * <pre> 1466 * The representative name for the entity. 1467 * </pre> 1468 * 1469 * <code>string name = 1;</code> 1470 * 1471 * @param value The name to set. 1472 * @return This builder for chaining. 1473 */ setName(java.lang.String value)1474 public Builder setName(java.lang.String value) { 1475 if (value == null) { 1476 throw new NullPointerException(); 1477 } 1478 name_ = value; 1479 bitField0_ |= 0x00000001; 1480 onChanged(); 1481 return this; 1482 } 1483 /** 1484 * 1485 * 1486 * <pre> 1487 * The representative name for the entity. 1488 * </pre> 1489 * 1490 * <code>string name = 1;</code> 1491 * 1492 * @return This builder for chaining. 1493 */ clearName()1494 public Builder clearName() { 1495 name_ = getDefaultInstance().getName(); 1496 bitField0_ = (bitField0_ & ~0x00000001); 1497 onChanged(); 1498 return this; 1499 } 1500 /** 1501 * 1502 * 1503 * <pre> 1504 * The representative name for the entity. 1505 * </pre> 1506 * 1507 * <code>string name = 1;</code> 1508 * 1509 * @param value The bytes for name to set. 1510 * @return This builder for chaining. 1511 */ setNameBytes(com.google.protobuf.ByteString value)1512 public Builder setNameBytes(com.google.protobuf.ByteString value) { 1513 if (value == null) { 1514 throw new NullPointerException(); 1515 } 1516 checkByteStringIsUtf8(value); 1517 name_ = value; 1518 bitField0_ |= 0x00000001; 1519 onChanged(); 1520 return this; 1521 } 1522 1523 private int type_ = 0; 1524 /** 1525 * 1526 * 1527 * <pre> 1528 * The entity type. 1529 * </pre> 1530 * 1531 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 1532 * 1533 * @return The enum numeric value on the wire for type. 1534 */ 1535 @java.lang.Override getTypeValue()1536 public int getTypeValue() { 1537 return type_; 1538 } 1539 /** 1540 * 1541 * 1542 * <pre> 1543 * The entity type. 1544 * </pre> 1545 * 1546 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 1547 * 1548 * @param value The enum numeric value on the wire for type to set. 1549 * @return This builder for chaining. 1550 */ setTypeValue(int value)1551 public Builder setTypeValue(int value) { 1552 type_ = value; 1553 bitField0_ |= 0x00000002; 1554 onChanged(); 1555 return this; 1556 } 1557 /** 1558 * 1559 * 1560 * <pre> 1561 * The entity type. 1562 * </pre> 1563 * 1564 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 1565 * 1566 * @return The type. 1567 */ 1568 @java.lang.Override getType()1569 public com.google.cloud.language.v1.Entity.Type getType() { 1570 com.google.cloud.language.v1.Entity.Type result = 1571 com.google.cloud.language.v1.Entity.Type.forNumber(type_); 1572 return result == null ? com.google.cloud.language.v1.Entity.Type.UNRECOGNIZED : result; 1573 } 1574 /** 1575 * 1576 * 1577 * <pre> 1578 * The entity type. 1579 * </pre> 1580 * 1581 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 1582 * 1583 * @param value The type to set. 1584 * @return This builder for chaining. 1585 */ setType(com.google.cloud.language.v1.Entity.Type value)1586 public Builder setType(com.google.cloud.language.v1.Entity.Type value) { 1587 if (value == null) { 1588 throw new NullPointerException(); 1589 } 1590 bitField0_ |= 0x00000002; 1591 type_ = value.getNumber(); 1592 onChanged(); 1593 return this; 1594 } 1595 /** 1596 * 1597 * 1598 * <pre> 1599 * The entity type. 1600 * </pre> 1601 * 1602 * <code>.google.cloud.language.v1.Entity.Type type = 2;</code> 1603 * 1604 * @return This builder for chaining. 1605 */ clearType()1606 public Builder clearType() { 1607 bitField0_ = (bitField0_ & ~0x00000002); 1608 type_ = 0; 1609 onChanged(); 1610 return this; 1611 } 1612 1613 private com.google.protobuf.MapField<java.lang.String, java.lang.String> metadata_; 1614 internalGetMetadata()1615 private com.google.protobuf.MapField<java.lang.String, java.lang.String> internalGetMetadata() { 1616 if (metadata_ == null) { 1617 return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry); 1618 } 1619 return metadata_; 1620 } 1621 1622 private com.google.protobuf.MapField<java.lang.String, java.lang.String> internalGetMutableMetadata()1623 internalGetMutableMetadata() { 1624 if (metadata_ == null) { 1625 metadata_ = 1626 com.google.protobuf.MapField.newMapField(MetadataDefaultEntryHolder.defaultEntry); 1627 } 1628 if (!metadata_.isMutable()) { 1629 metadata_ = metadata_.copy(); 1630 } 1631 bitField0_ |= 0x00000004; 1632 onChanged(); 1633 return metadata_; 1634 } 1635 getMetadataCount()1636 public int getMetadataCount() { 1637 return internalGetMetadata().getMap().size(); 1638 } 1639 /** 1640 * 1641 * 1642 * <pre> 1643 * Metadata associated with the entity. 1644 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1645 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1646 * associated with other entity types, see the Type table below. 1647 * </pre> 1648 * 1649 * <code>map<string, string> metadata = 3;</code> 1650 */ 1651 @java.lang.Override containsMetadata(java.lang.String key)1652 public boolean containsMetadata(java.lang.String key) { 1653 if (key == null) { 1654 throw new NullPointerException("map key"); 1655 } 1656 return internalGetMetadata().getMap().containsKey(key); 1657 } 1658 /** Use {@link #getMetadataMap()} instead. */ 1659 @java.lang.Override 1660 @java.lang.Deprecated getMetadata()1661 public java.util.Map<java.lang.String, java.lang.String> getMetadata() { 1662 return getMetadataMap(); 1663 } 1664 /** 1665 * 1666 * 1667 * <pre> 1668 * Metadata associated with the entity. 1669 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1670 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1671 * associated with other entity types, see the Type table below. 1672 * </pre> 1673 * 1674 * <code>map<string, string> metadata = 3;</code> 1675 */ 1676 @java.lang.Override getMetadataMap()1677 public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() { 1678 return internalGetMetadata().getMap(); 1679 } 1680 /** 1681 * 1682 * 1683 * <pre> 1684 * Metadata associated with the entity. 1685 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1686 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1687 * associated with other entity types, see the Type table below. 1688 * </pre> 1689 * 1690 * <code>map<string, string> metadata = 3;</code> 1691 */ 1692 @java.lang.Override getMetadataOrDefault( java.lang.String key, java.lang.String defaultValue)1693 public /* nullable */ java.lang.String getMetadataOrDefault( 1694 java.lang.String key, 1695 /* nullable */ 1696 java.lang.String defaultValue) { 1697 if (key == null) { 1698 throw new NullPointerException("map key"); 1699 } 1700 java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap(); 1701 return map.containsKey(key) ? map.get(key) : defaultValue; 1702 } 1703 /** 1704 * 1705 * 1706 * <pre> 1707 * Metadata associated with the entity. 1708 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1709 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1710 * associated with other entity types, see the Type table below. 1711 * </pre> 1712 * 1713 * <code>map<string, string> metadata = 3;</code> 1714 */ 1715 @java.lang.Override getMetadataOrThrow(java.lang.String key)1716 public java.lang.String getMetadataOrThrow(java.lang.String key) { 1717 if (key == null) { 1718 throw new NullPointerException("map key"); 1719 } 1720 java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap(); 1721 if (!map.containsKey(key)) { 1722 throw new java.lang.IllegalArgumentException(); 1723 } 1724 return map.get(key); 1725 } 1726 clearMetadata()1727 public Builder clearMetadata() { 1728 bitField0_ = (bitField0_ & ~0x00000004); 1729 internalGetMutableMetadata().getMutableMap().clear(); 1730 return this; 1731 } 1732 /** 1733 * 1734 * 1735 * <pre> 1736 * Metadata associated with the entity. 1737 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1738 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1739 * associated with other entity types, see the Type table below. 1740 * </pre> 1741 * 1742 * <code>map<string, string> metadata = 3;</code> 1743 */ removeMetadata(java.lang.String key)1744 public Builder removeMetadata(java.lang.String key) { 1745 if (key == null) { 1746 throw new NullPointerException("map key"); 1747 } 1748 internalGetMutableMetadata().getMutableMap().remove(key); 1749 return this; 1750 } 1751 /** Use alternate mutation accessors instead. */ 1752 @java.lang.Deprecated getMutableMetadata()1753 public java.util.Map<java.lang.String, java.lang.String> getMutableMetadata() { 1754 bitField0_ |= 0x00000004; 1755 return internalGetMutableMetadata().getMutableMap(); 1756 } 1757 /** 1758 * 1759 * 1760 * <pre> 1761 * Metadata associated with the entity. 1762 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1763 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1764 * associated with other entity types, see the Type table below. 1765 * </pre> 1766 * 1767 * <code>map<string, string> metadata = 3;</code> 1768 */ putMetadata(java.lang.String key, java.lang.String value)1769 public Builder putMetadata(java.lang.String key, java.lang.String value) { 1770 if (key == null) { 1771 throw new NullPointerException("map key"); 1772 } 1773 if (value == null) { 1774 throw new NullPointerException("map value"); 1775 } 1776 internalGetMutableMetadata().getMutableMap().put(key, value); 1777 bitField0_ |= 0x00000004; 1778 return this; 1779 } 1780 /** 1781 * 1782 * 1783 * <pre> 1784 * Metadata associated with the entity. 1785 * For most entity types, the metadata is a Wikipedia URL (`wikipedia_url`) 1786 * and Knowledge Graph MID (`mid`), if they are available. For the metadata 1787 * associated with other entity types, see the Type table below. 1788 * </pre> 1789 * 1790 * <code>map<string, string> metadata = 3;</code> 1791 */ putAllMetadata(java.util.Map<java.lang.String, java.lang.String> values)1792 public Builder putAllMetadata(java.util.Map<java.lang.String, java.lang.String> values) { 1793 internalGetMutableMetadata().getMutableMap().putAll(values); 1794 bitField0_ |= 0x00000004; 1795 return this; 1796 } 1797 1798 private float salience_; 1799 /** 1800 * 1801 * 1802 * <pre> 1803 * The salience score associated with the entity in the [0, 1.0] range. 1804 * The salience score for an entity provides information about the 1805 * importance or centrality of that entity to the entire document text. 1806 * Scores closer to 0 are less salient, while scores closer to 1.0 are highly 1807 * salient. 1808 * </pre> 1809 * 1810 * <code>float salience = 4;</code> 1811 * 1812 * @return The salience. 1813 */ 1814 @java.lang.Override getSalience()1815 public float getSalience() { 1816 return salience_; 1817 } 1818 /** 1819 * 1820 * 1821 * <pre> 1822 * The salience score associated with the entity in the [0, 1.0] range. 1823 * The salience score for an entity provides information about the 1824 * importance or centrality of that entity to the entire document text. 1825 * Scores closer to 0 are less salient, while scores closer to 1.0 are highly 1826 * salient. 1827 * </pre> 1828 * 1829 * <code>float salience = 4;</code> 1830 * 1831 * @param value The salience to set. 1832 * @return This builder for chaining. 1833 */ setSalience(float value)1834 public Builder setSalience(float value) { 1835 1836 salience_ = value; 1837 bitField0_ |= 0x00000008; 1838 onChanged(); 1839 return this; 1840 } 1841 /** 1842 * 1843 * 1844 * <pre> 1845 * The salience score associated with the entity in the [0, 1.0] range. 1846 * The salience score for an entity provides information about the 1847 * importance or centrality of that entity to the entire document text. 1848 * Scores closer to 0 are less salient, while scores closer to 1.0 are highly 1849 * salient. 1850 * </pre> 1851 * 1852 * <code>float salience = 4;</code> 1853 * 1854 * @return This builder for chaining. 1855 */ clearSalience()1856 public Builder clearSalience() { 1857 bitField0_ = (bitField0_ & ~0x00000008); 1858 salience_ = 0F; 1859 onChanged(); 1860 return this; 1861 } 1862 1863 private java.util.List<com.google.cloud.language.v1.EntityMention> mentions_ = 1864 java.util.Collections.emptyList(); 1865 ensureMentionsIsMutable()1866 private void ensureMentionsIsMutable() { 1867 if (!((bitField0_ & 0x00000010) != 0)) { 1868 mentions_ = new java.util.ArrayList<com.google.cloud.language.v1.EntityMention>(mentions_); 1869 bitField0_ |= 0x00000010; 1870 } 1871 } 1872 1873 private com.google.protobuf.RepeatedFieldBuilderV3< 1874 com.google.cloud.language.v1.EntityMention, 1875 com.google.cloud.language.v1.EntityMention.Builder, 1876 com.google.cloud.language.v1.EntityMentionOrBuilder> 1877 mentionsBuilder_; 1878 1879 /** 1880 * 1881 * 1882 * <pre> 1883 * The mentions of this entity in the input document. The API currently 1884 * supports proper noun mentions. 1885 * </pre> 1886 * 1887 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1888 */ getMentionsList()1889 public java.util.List<com.google.cloud.language.v1.EntityMention> getMentionsList() { 1890 if (mentionsBuilder_ == null) { 1891 return java.util.Collections.unmodifiableList(mentions_); 1892 } else { 1893 return mentionsBuilder_.getMessageList(); 1894 } 1895 } 1896 /** 1897 * 1898 * 1899 * <pre> 1900 * The mentions of this entity in the input document. The API currently 1901 * supports proper noun mentions. 1902 * </pre> 1903 * 1904 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1905 */ getMentionsCount()1906 public int getMentionsCount() { 1907 if (mentionsBuilder_ == null) { 1908 return mentions_.size(); 1909 } else { 1910 return mentionsBuilder_.getCount(); 1911 } 1912 } 1913 /** 1914 * 1915 * 1916 * <pre> 1917 * The mentions of this entity in the input document. The API currently 1918 * supports proper noun mentions. 1919 * </pre> 1920 * 1921 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1922 */ getMentions(int index)1923 public com.google.cloud.language.v1.EntityMention getMentions(int index) { 1924 if (mentionsBuilder_ == null) { 1925 return mentions_.get(index); 1926 } else { 1927 return mentionsBuilder_.getMessage(index); 1928 } 1929 } 1930 /** 1931 * 1932 * 1933 * <pre> 1934 * The mentions of this entity in the input document. The API currently 1935 * supports proper noun mentions. 1936 * </pre> 1937 * 1938 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1939 */ setMentions(int index, com.google.cloud.language.v1.EntityMention value)1940 public Builder setMentions(int index, com.google.cloud.language.v1.EntityMention value) { 1941 if (mentionsBuilder_ == null) { 1942 if (value == null) { 1943 throw new NullPointerException(); 1944 } 1945 ensureMentionsIsMutable(); 1946 mentions_.set(index, value); 1947 onChanged(); 1948 } else { 1949 mentionsBuilder_.setMessage(index, value); 1950 } 1951 return this; 1952 } 1953 /** 1954 * 1955 * 1956 * <pre> 1957 * The mentions of this entity in the input document. The API currently 1958 * supports proper noun mentions. 1959 * </pre> 1960 * 1961 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1962 */ setMentions( int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue)1963 public Builder setMentions( 1964 int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue) { 1965 if (mentionsBuilder_ == null) { 1966 ensureMentionsIsMutable(); 1967 mentions_.set(index, builderForValue.build()); 1968 onChanged(); 1969 } else { 1970 mentionsBuilder_.setMessage(index, builderForValue.build()); 1971 } 1972 return this; 1973 } 1974 /** 1975 * 1976 * 1977 * <pre> 1978 * The mentions of this entity in the input document. The API currently 1979 * supports proper noun mentions. 1980 * </pre> 1981 * 1982 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 1983 */ addMentions(com.google.cloud.language.v1.EntityMention value)1984 public Builder addMentions(com.google.cloud.language.v1.EntityMention value) { 1985 if (mentionsBuilder_ == null) { 1986 if (value == null) { 1987 throw new NullPointerException(); 1988 } 1989 ensureMentionsIsMutable(); 1990 mentions_.add(value); 1991 onChanged(); 1992 } else { 1993 mentionsBuilder_.addMessage(value); 1994 } 1995 return this; 1996 } 1997 /** 1998 * 1999 * 2000 * <pre> 2001 * The mentions of this entity in the input document. The API currently 2002 * supports proper noun mentions. 2003 * </pre> 2004 * 2005 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2006 */ addMentions(int index, com.google.cloud.language.v1.EntityMention value)2007 public Builder addMentions(int index, com.google.cloud.language.v1.EntityMention value) { 2008 if (mentionsBuilder_ == null) { 2009 if (value == null) { 2010 throw new NullPointerException(); 2011 } 2012 ensureMentionsIsMutable(); 2013 mentions_.add(index, value); 2014 onChanged(); 2015 } else { 2016 mentionsBuilder_.addMessage(index, value); 2017 } 2018 return this; 2019 } 2020 /** 2021 * 2022 * 2023 * <pre> 2024 * The mentions of this entity in the input document. The API currently 2025 * supports proper noun mentions. 2026 * </pre> 2027 * 2028 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2029 */ addMentions(com.google.cloud.language.v1.EntityMention.Builder builderForValue)2030 public Builder addMentions(com.google.cloud.language.v1.EntityMention.Builder builderForValue) { 2031 if (mentionsBuilder_ == null) { 2032 ensureMentionsIsMutable(); 2033 mentions_.add(builderForValue.build()); 2034 onChanged(); 2035 } else { 2036 mentionsBuilder_.addMessage(builderForValue.build()); 2037 } 2038 return this; 2039 } 2040 /** 2041 * 2042 * 2043 * <pre> 2044 * The mentions of this entity in the input document. The API currently 2045 * supports proper noun mentions. 2046 * </pre> 2047 * 2048 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2049 */ addMentions( int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue)2050 public Builder addMentions( 2051 int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue) { 2052 if (mentionsBuilder_ == null) { 2053 ensureMentionsIsMutable(); 2054 mentions_.add(index, builderForValue.build()); 2055 onChanged(); 2056 } else { 2057 mentionsBuilder_.addMessage(index, builderForValue.build()); 2058 } 2059 return this; 2060 } 2061 /** 2062 * 2063 * 2064 * <pre> 2065 * The mentions of this entity in the input document. The API currently 2066 * supports proper noun mentions. 2067 * </pre> 2068 * 2069 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2070 */ addAllMentions( java.lang.Iterable<? extends com.google.cloud.language.v1.EntityMention> values)2071 public Builder addAllMentions( 2072 java.lang.Iterable<? extends com.google.cloud.language.v1.EntityMention> values) { 2073 if (mentionsBuilder_ == null) { 2074 ensureMentionsIsMutable(); 2075 com.google.protobuf.AbstractMessageLite.Builder.addAll(values, mentions_); 2076 onChanged(); 2077 } else { 2078 mentionsBuilder_.addAllMessages(values); 2079 } 2080 return this; 2081 } 2082 /** 2083 * 2084 * 2085 * <pre> 2086 * The mentions of this entity in the input document. The API currently 2087 * supports proper noun mentions. 2088 * </pre> 2089 * 2090 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2091 */ clearMentions()2092 public Builder clearMentions() { 2093 if (mentionsBuilder_ == null) { 2094 mentions_ = java.util.Collections.emptyList(); 2095 bitField0_ = (bitField0_ & ~0x00000010); 2096 onChanged(); 2097 } else { 2098 mentionsBuilder_.clear(); 2099 } 2100 return this; 2101 } 2102 /** 2103 * 2104 * 2105 * <pre> 2106 * The mentions of this entity in the input document. The API currently 2107 * supports proper noun mentions. 2108 * </pre> 2109 * 2110 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2111 */ removeMentions(int index)2112 public Builder removeMentions(int index) { 2113 if (mentionsBuilder_ == null) { 2114 ensureMentionsIsMutable(); 2115 mentions_.remove(index); 2116 onChanged(); 2117 } else { 2118 mentionsBuilder_.remove(index); 2119 } 2120 return this; 2121 } 2122 /** 2123 * 2124 * 2125 * <pre> 2126 * The mentions of this entity in the input document. The API currently 2127 * supports proper noun mentions. 2128 * </pre> 2129 * 2130 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2131 */ getMentionsBuilder(int index)2132 public com.google.cloud.language.v1.EntityMention.Builder getMentionsBuilder(int index) { 2133 return getMentionsFieldBuilder().getBuilder(index); 2134 } 2135 /** 2136 * 2137 * 2138 * <pre> 2139 * The mentions of this entity in the input document. The API currently 2140 * supports proper noun mentions. 2141 * </pre> 2142 * 2143 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2144 */ getMentionsOrBuilder(int index)2145 public com.google.cloud.language.v1.EntityMentionOrBuilder getMentionsOrBuilder(int index) { 2146 if (mentionsBuilder_ == null) { 2147 return mentions_.get(index); 2148 } else { 2149 return mentionsBuilder_.getMessageOrBuilder(index); 2150 } 2151 } 2152 /** 2153 * 2154 * 2155 * <pre> 2156 * The mentions of this entity in the input document. The API currently 2157 * supports proper noun mentions. 2158 * </pre> 2159 * 2160 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2161 */ 2162 public java.util.List<? extends com.google.cloud.language.v1.EntityMentionOrBuilder> getMentionsOrBuilderList()2163 getMentionsOrBuilderList() { 2164 if (mentionsBuilder_ != null) { 2165 return mentionsBuilder_.getMessageOrBuilderList(); 2166 } else { 2167 return java.util.Collections.unmodifiableList(mentions_); 2168 } 2169 } 2170 /** 2171 * 2172 * 2173 * <pre> 2174 * The mentions of this entity in the input document. The API currently 2175 * supports proper noun mentions. 2176 * </pre> 2177 * 2178 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2179 */ addMentionsBuilder()2180 public com.google.cloud.language.v1.EntityMention.Builder addMentionsBuilder() { 2181 return getMentionsFieldBuilder() 2182 .addBuilder(com.google.cloud.language.v1.EntityMention.getDefaultInstance()); 2183 } 2184 /** 2185 * 2186 * 2187 * <pre> 2188 * The mentions of this entity in the input document. The API currently 2189 * supports proper noun mentions. 2190 * </pre> 2191 * 2192 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2193 */ addMentionsBuilder(int index)2194 public com.google.cloud.language.v1.EntityMention.Builder addMentionsBuilder(int index) { 2195 return getMentionsFieldBuilder() 2196 .addBuilder(index, com.google.cloud.language.v1.EntityMention.getDefaultInstance()); 2197 } 2198 /** 2199 * 2200 * 2201 * <pre> 2202 * The mentions of this entity in the input document. The API currently 2203 * supports proper noun mentions. 2204 * </pre> 2205 * 2206 * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code> 2207 */ 2208 public java.util.List<com.google.cloud.language.v1.EntityMention.Builder> getMentionsBuilderList()2209 getMentionsBuilderList() { 2210 return getMentionsFieldBuilder().getBuilderList(); 2211 } 2212 2213 private com.google.protobuf.RepeatedFieldBuilderV3< 2214 com.google.cloud.language.v1.EntityMention, 2215 com.google.cloud.language.v1.EntityMention.Builder, 2216 com.google.cloud.language.v1.EntityMentionOrBuilder> getMentionsFieldBuilder()2217 getMentionsFieldBuilder() { 2218 if (mentionsBuilder_ == null) { 2219 mentionsBuilder_ = 2220 new com.google.protobuf.RepeatedFieldBuilderV3< 2221 com.google.cloud.language.v1.EntityMention, 2222 com.google.cloud.language.v1.EntityMention.Builder, 2223 com.google.cloud.language.v1.EntityMentionOrBuilder>( 2224 mentions_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); 2225 mentions_ = null; 2226 } 2227 return mentionsBuilder_; 2228 } 2229 2230 private com.google.cloud.language.v1.Sentiment sentiment_; 2231 private com.google.protobuf.SingleFieldBuilderV3< 2232 com.google.cloud.language.v1.Sentiment, 2233 com.google.cloud.language.v1.Sentiment.Builder, 2234 com.google.cloud.language.v1.SentimentOrBuilder> 2235 sentimentBuilder_; 2236 /** 2237 * 2238 * 2239 * <pre> 2240 * For calls to [AnalyzeEntitySentiment][] or if 2241 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2242 * is set to true, this field will contain the aggregate sentiment expressed 2243 * for this entity in the provided document. 2244 * </pre> 2245 * 2246 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2247 * 2248 * @return Whether the sentiment field is set. 2249 */ hasSentiment()2250 public boolean hasSentiment() { 2251 return ((bitField0_ & 0x00000020) != 0); 2252 } 2253 /** 2254 * 2255 * 2256 * <pre> 2257 * For calls to [AnalyzeEntitySentiment][] or if 2258 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2259 * is set to true, this field will contain the aggregate sentiment expressed 2260 * for this entity in the provided document. 2261 * </pre> 2262 * 2263 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2264 * 2265 * @return The sentiment. 2266 */ getSentiment()2267 public com.google.cloud.language.v1.Sentiment getSentiment() { 2268 if (sentimentBuilder_ == null) { 2269 return sentiment_ == null 2270 ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() 2271 : sentiment_; 2272 } else { 2273 return sentimentBuilder_.getMessage(); 2274 } 2275 } 2276 /** 2277 * 2278 * 2279 * <pre> 2280 * For calls to [AnalyzeEntitySentiment][] or if 2281 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2282 * is set to true, this field will contain the aggregate sentiment expressed 2283 * for this entity in the provided document. 2284 * </pre> 2285 * 2286 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2287 */ setSentiment(com.google.cloud.language.v1.Sentiment value)2288 public Builder setSentiment(com.google.cloud.language.v1.Sentiment value) { 2289 if (sentimentBuilder_ == null) { 2290 if (value == null) { 2291 throw new NullPointerException(); 2292 } 2293 sentiment_ = value; 2294 } else { 2295 sentimentBuilder_.setMessage(value); 2296 } 2297 bitField0_ |= 0x00000020; 2298 onChanged(); 2299 return this; 2300 } 2301 /** 2302 * 2303 * 2304 * <pre> 2305 * For calls to [AnalyzeEntitySentiment][] or if 2306 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2307 * is set to true, this field will contain the aggregate sentiment expressed 2308 * for this entity in the provided document. 2309 * </pre> 2310 * 2311 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2312 */ setSentiment(com.google.cloud.language.v1.Sentiment.Builder builderForValue)2313 public Builder setSentiment(com.google.cloud.language.v1.Sentiment.Builder builderForValue) { 2314 if (sentimentBuilder_ == null) { 2315 sentiment_ = builderForValue.build(); 2316 } else { 2317 sentimentBuilder_.setMessage(builderForValue.build()); 2318 } 2319 bitField0_ |= 0x00000020; 2320 onChanged(); 2321 return this; 2322 } 2323 /** 2324 * 2325 * 2326 * <pre> 2327 * For calls to [AnalyzeEntitySentiment][] or if 2328 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2329 * is set to true, this field will contain the aggregate sentiment expressed 2330 * for this entity in the provided document. 2331 * </pre> 2332 * 2333 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2334 */ mergeSentiment(com.google.cloud.language.v1.Sentiment value)2335 public Builder mergeSentiment(com.google.cloud.language.v1.Sentiment value) { 2336 if (sentimentBuilder_ == null) { 2337 if (((bitField0_ & 0x00000020) != 0) 2338 && sentiment_ != null 2339 && sentiment_ != com.google.cloud.language.v1.Sentiment.getDefaultInstance()) { 2340 getSentimentBuilder().mergeFrom(value); 2341 } else { 2342 sentiment_ = value; 2343 } 2344 } else { 2345 sentimentBuilder_.mergeFrom(value); 2346 } 2347 bitField0_ |= 0x00000020; 2348 onChanged(); 2349 return this; 2350 } 2351 /** 2352 * 2353 * 2354 * <pre> 2355 * For calls to [AnalyzeEntitySentiment][] or if 2356 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2357 * is set to true, this field will contain the aggregate sentiment expressed 2358 * for this entity in the provided document. 2359 * </pre> 2360 * 2361 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2362 */ clearSentiment()2363 public Builder clearSentiment() { 2364 bitField0_ = (bitField0_ & ~0x00000020); 2365 sentiment_ = null; 2366 if (sentimentBuilder_ != null) { 2367 sentimentBuilder_.dispose(); 2368 sentimentBuilder_ = null; 2369 } 2370 onChanged(); 2371 return this; 2372 } 2373 /** 2374 * 2375 * 2376 * <pre> 2377 * For calls to [AnalyzeEntitySentiment][] or if 2378 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2379 * is set to true, this field will contain the aggregate sentiment expressed 2380 * for this entity in the provided document. 2381 * </pre> 2382 * 2383 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2384 */ getSentimentBuilder()2385 public com.google.cloud.language.v1.Sentiment.Builder getSentimentBuilder() { 2386 bitField0_ |= 0x00000020; 2387 onChanged(); 2388 return getSentimentFieldBuilder().getBuilder(); 2389 } 2390 /** 2391 * 2392 * 2393 * <pre> 2394 * For calls to [AnalyzeEntitySentiment][] or if 2395 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2396 * is set to true, this field will contain the aggregate sentiment expressed 2397 * for this entity in the provided document. 2398 * </pre> 2399 * 2400 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2401 */ getSentimentOrBuilder()2402 public com.google.cloud.language.v1.SentimentOrBuilder getSentimentOrBuilder() { 2403 if (sentimentBuilder_ != null) { 2404 return sentimentBuilder_.getMessageOrBuilder(); 2405 } else { 2406 return sentiment_ == null 2407 ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() 2408 : sentiment_; 2409 } 2410 } 2411 /** 2412 * 2413 * 2414 * <pre> 2415 * For calls to [AnalyzeEntitySentiment][] or if 2416 * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] 2417 * is set to true, this field will contain the aggregate sentiment expressed 2418 * for this entity in the provided document. 2419 * </pre> 2420 * 2421 * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code> 2422 */ 2423 private com.google.protobuf.SingleFieldBuilderV3< 2424 com.google.cloud.language.v1.Sentiment, 2425 com.google.cloud.language.v1.Sentiment.Builder, 2426 com.google.cloud.language.v1.SentimentOrBuilder> getSentimentFieldBuilder()2427 getSentimentFieldBuilder() { 2428 if (sentimentBuilder_ == null) { 2429 sentimentBuilder_ = 2430 new com.google.protobuf.SingleFieldBuilderV3< 2431 com.google.cloud.language.v1.Sentiment, 2432 com.google.cloud.language.v1.Sentiment.Builder, 2433 com.google.cloud.language.v1.SentimentOrBuilder>( 2434 getSentiment(), getParentForChildren(), isClean()); 2435 sentiment_ = null; 2436 } 2437 return sentimentBuilder_; 2438 } 2439 2440 @java.lang.Override setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields)2441 public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { 2442 return super.setUnknownFields(unknownFields); 2443 } 2444 2445 @java.lang.Override mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields)2446 public final Builder mergeUnknownFields( 2447 final com.google.protobuf.UnknownFieldSet unknownFields) { 2448 return super.mergeUnknownFields(unknownFields); 2449 } 2450 2451 // @@protoc_insertion_point(builder_scope:google.cloud.language.v1.Entity) 2452 } 2453 2454 // @@protoc_insertion_point(class_scope:google.cloud.language.v1.Entity) 2455 private static final com.google.cloud.language.v1.Entity DEFAULT_INSTANCE; 2456 2457 static { 2458 DEFAULT_INSTANCE = new com.google.cloud.language.v1.Entity(); 2459 } 2460 getDefaultInstance()2461 public static com.google.cloud.language.v1.Entity getDefaultInstance() { 2462 return DEFAULT_INSTANCE; 2463 } 2464 2465 private static final com.google.protobuf.Parser<Entity> PARSER = 2466 new com.google.protobuf.AbstractParser<Entity>() { 2467 @java.lang.Override 2468 public Entity parsePartialFrom( 2469 com.google.protobuf.CodedInputStream input, 2470 com.google.protobuf.ExtensionRegistryLite extensionRegistry) 2471 throws com.google.protobuf.InvalidProtocolBufferException { 2472 Builder builder = newBuilder(); 2473 try { 2474 builder.mergeFrom(input, extensionRegistry); 2475 } catch (com.google.protobuf.InvalidProtocolBufferException e) { 2476 throw e.setUnfinishedMessage(builder.buildPartial()); 2477 } catch (com.google.protobuf.UninitializedMessageException e) { 2478 throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); 2479 } catch (java.io.IOException e) { 2480 throw new com.google.protobuf.InvalidProtocolBufferException(e) 2481 .setUnfinishedMessage(builder.buildPartial()); 2482 } 2483 return builder.buildPartial(); 2484 } 2485 }; 2486 parser()2487 public static com.google.protobuf.Parser<Entity> parser() { 2488 return PARSER; 2489 } 2490 2491 @java.lang.Override getParserForType()2492 public com.google.protobuf.Parser<Entity> getParserForType() { 2493 return PARSER; 2494 } 2495 2496 @java.lang.Override getDefaultInstanceForType()2497 public com.google.cloud.language.v1.Entity getDefaultInstanceForType() { 2498 return DEFAULT_INSTANCE; 2499 } 2500 } 2501