// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/language/v1/language_service.proto

package com.google.cloud.language.v1;

/**
 * <pre>
 * Represents a phrase in the text that is a known entity, such as
 * a person, an organization, or location. The API associates information, such
 * as salience and mentions, with entities.
 * </pre>
 *
 * Protobuf type {@code google.cloud.language.v1.Entity}
 */
public  final class Entity extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.cloud.language.v1.Entity)
    EntityOrBuilder {
private static final long serialVersionUID = 0L;
  // Use Entity.newBuilder() to construct.
  private Entity(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private Entity() {
    name_ = "";
    type_ = 0;
    salience_ = 0F;
    mentions_ = java.util.Collections.emptyList();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private Entity(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    int mutable_bitField0_ = 0;
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!parseUnknownFieldProto3(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
          case 10: {
            java.lang.String s = input.readStringRequireUtf8();

            name_ = s;
            break;
          }
          case 16: {
            int rawValue = input.readEnum();

            type_ = rawValue;
            break;
          }
          case 26: {
            if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
              metadata_ = com.google.protobuf.MapField.newMapField(
                  MetadataDefaultEntryHolder.defaultEntry);
              mutable_bitField0_ |= 0x00000004;
            }
            com.google.protobuf.MapEntry<java.lang.String, java.lang.String>
            metadata__ = input.readMessage(
                MetadataDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry);
            metadata_.getMutableMap().put(
                metadata__.getKey(), metadata__.getValue());
            break;
          }
          case 37: {

            salience_ = input.readFloat();
            break;
          }
          case 42: {
            if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
              mentions_ = new java.util.ArrayList<com.google.cloud.language.v1.EntityMention>();
              mutable_bitField0_ |= 0x00000010;
            }
            mentions_.add(
                input.readMessage(com.google.cloud.language.v1.EntityMention.parser(), extensionRegistry));
            break;
          }
          case 50: {
            com.google.cloud.language.v1.Sentiment.Builder subBuilder = null;
            if (sentiment_ != null) {
              subBuilder = sentiment_.toBuilder();
            }
            sentiment_ = input.readMessage(com.google.cloud.language.v1.Sentiment.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(sentiment_);
              sentiment_ = subBuilder.buildPartial();
            }

            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
        mentions_ = java.util.Collections.unmodifiableList(mentions_);
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_descriptor;
  }

  @SuppressWarnings({"rawtypes"})
  protected com.google.protobuf.MapField internalGetMapField(
      int number) {
    switch (number) {
      case 3:
        return internalGetMetadata();
      default:
        throw new RuntimeException(
            "Invalid map field number: " + number);
    }
  }
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.language.v1.Entity.class, com.google.cloud.language.v1.Entity.Builder.class);
  }

  /**
   * <pre>
   * The type of the entity.
   * </pre>
   *
   * Protobuf enum {@code google.cloud.language.v1.Entity.Type}
   */
  public enum Type
      implements com.google.protobuf.ProtocolMessageEnum {
    /**
     * <pre>
     * Unknown
     * </pre>
     *
     * <code>UNKNOWN = 0;</code>
     */
    UNKNOWN(0),
    /**
     * <pre>
     * Person
     * </pre>
     *
     * <code>PERSON = 1;</code>
     */
    PERSON(1),
    /**
     * <pre>
     * Location
     * </pre>
     *
     * <code>LOCATION = 2;</code>
     */
    LOCATION(2),
    /**
     * <pre>
     * Organization
     * </pre>
     *
     * <code>ORGANIZATION = 3;</code>
     */
    ORGANIZATION(3),
    /**
     * <pre>
     * Event
     * </pre>
     *
     * <code>EVENT = 4;</code>
     */
    EVENT(4),
    /**
     * <pre>
     * Work of art
     * </pre>
     *
     * <code>WORK_OF_ART = 5;</code>
     */
    WORK_OF_ART(5),
    /**
     * <pre>
     * Consumer goods
     * </pre>
     *
     * <code>CONSUMER_GOOD = 6;</code>
     */
    CONSUMER_GOOD(6),
    /**
     * <pre>
     * Other types
     * </pre>
     *
     * <code>OTHER = 7;</code>
     */
    OTHER(7),
    UNRECOGNIZED(-1),
    ;

    /**
     * <pre>
     * Unknown
     * </pre>
     *
     * <code>UNKNOWN = 0;</code>
     */
    public static final int UNKNOWN_VALUE = 0;
    /**
     * <pre>
     * Person
     * </pre>
     *
     * <code>PERSON = 1;</code>
     */
    public static final int PERSON_VALUE = 1;
    /**
     * <pre>
     * Location
     * </pre>
     *
     * <code>LOCATION = 2;</code>
     */
    public static final int LOCATION_VALUE = 2;
    /**
     * <pre>
     * Organization
     * </pre>
     *
     * <code>ORGANIZATION = 3;</code>
     */
    public static final int ORGANIZATION_VALUE = 3;
    /**
     * <pre>
     * Event
     * </pre>
     *
     * <code>EVENT = 4;</code>
     */
    public static final int EVENT_VALUE = 4;
    /**
     * <pre>
     * Work of art
     * </pre>
     *
     * <code>WORK_OF_ART = 5;</code>
     */
    public static final int WORK_OF_ART_VALUE = 5;
    /**
     * <pre>
     * Consumer goods
     * </pre>
     *
     * <code>CONSUMER_GOOD = 6;</code>
     */
    public static final int CONSUMER_GOOD_VALUE = 6;
    /**
     * <pre>
     * Other types
     * </pre>
     *
     * <code>OTHER = 7;</code>
     */
    public static final int OTHER_VALUE = 7;


    public final int getNumber() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalArgumentException(
            "Can't get the number of an unknown enum value.");
      }
      return value;
    }

    /**
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static Type valueOf(int value) {
      return forNumber(value);
    }

    public static Type forNumber(int value) {
      switch (value) {
        case 0: return UNKNOWN;
        case 1: return PERSON;
        case 2: return LOCATION;
        case 3: return ORGANIZATION;
        case 4: return EVENT;
        case 5: return WORK_OF_ART;
        case 6: return CONSUMER_GOOD;
        case 7: return OTHER;
        default: return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<Type>
        internalGetValueMap() {
      return internalValueMap;
    }
    private static final com.google.protobuf.Internal.EnumLiteMap<
        Type> internalValueMap =
          new com.google.protobuf.Internal.EnumLiteMap<Type>() {
            public Type findValueByNumber(int number) {
              return Type.forNumber(number);
            }
          };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor
        getValueDescriptor() {
      return getDescriptor().getValues().get(ordinal());
    }
    public final com.google.protobuf.Descriptors.EnumDescriptor
        getDescriptorForType() {
      return getDescriptor();
    }
    public static final com.google.protobuf.Descriptors.EnumDescriptor
        getDescriptor() {
      return com.google.cloud.language.v1.Entity.getDescriptor().getEnumTypes().get(0);
    }

    private static final Type[] VALUES = values();

    public static Type valueOf(
        com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException(
          "EnumValueDescriptor is not for this type.");
      }
      if (desc.getIndex() == -1) {
        return UNRECOGNIZED;
      }
      return VALUES[desc.getIndex()];
    }

    private final int value;

    private Type(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:google.cloud.language.v1.Entity.Type)
  }

  private int bitField0_;
  public static final int NAME_FIELD_NUMBER = 1;
  private volatile java.lang.Object name_;
  /**
   * <pre>
   * The representative name for the entity.
   * </pre>
   *
   * <code>string name = 1;</code>
   */
  public java.lang.String getName() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      name_ = s;
      return s;
    }
  }
  /**
   * <pre>
   * The representative name for the entity.
   * </pre>
   *
   * <code>string name = 1;</code>
   */
  public com.google.protobuf.ByteString
      getNameBytes() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      name_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int TYPE_FIELD_NUMBER = 2;
  private int type_;
  /**
   * <pre>
   * The entity type.
   * </pre>
   *
   * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
   */
  public int getTypeValue() {
    return type_;
  }
  /**
   * <pre>
   * The entity type.
   * </pre>
   *
   * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
   */
  public com.google.cloud.language.v1.Entity.Type getType() {
    com.google.cloud.language.v1.Entity.Type result = com.google.cloud.language.v1.Entity.Type.valueOf(type_);
    return result == null ? com.google.cloud.language.v1.Entity.Type.UNRECOGNIZED : result;
  }

  public static final int METADATA_FIELD_NUMBER = 3;
  private static final class MetadataDefaultEntryHolder {
    static final com.google.protobuf.MapEntry<
        java.lang.String, java.lang.String> defaultEntry =
            com.google.protobuf.MapEntry
            .<java.lang.String, java.lang.String>newDefaultInstance(
                com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_MetadataEntry_descriptor, 
                com.google.protobuf.WireFormat.FieldType.STRING,
                "",
                com.google.protobuf.WireFormat.FieldType.STRING,
                "");
  }
  private com.google.protobuf.MapField<
      java.lang.String, java.lang.String> metadata_;
  private com.google.protobuf.MapField<java.lang.String, java.lang.String>
  internalGetMetadata() {
    if (metadata_ == null) {
      return com.google.protobuf.MapField.emptyMapField(
          MetadataDefaultEntryHolder.defaultEntry);
    }
    return metadata_;
  }

  public int getMetadataCount() {
    return internalGetMetadata().getMap().size();
  }
  /**
   * <pre>
   * Metadata associated with the entity.
   * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
   * available. The associated keys are "wikipedia_url" and "mid", respectively.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 3;</code>
   */

  public boolean containsMetadata(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    return internalGetMetadata().getMap().containsKey(key);
  }
  /**
   * Use {@link #getMetadataMap()} instead.
   */
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
    return getMetadataMap();
  }
  /**
   * <pre>
   * Metadata associated with the entity.
   * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
   * available. The associated keys are "wikipedia_url" and "mid", respectively.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 3;</code>
   */

  public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
    return internalGetMetadata().getMap();
  }
  /**
   * <pre>
   * Metadata associated with the entity.
   * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
   * available. The associated keys are "wikipedia_url" and "mid", respectively.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 3;</code>
   */

  public java.lang.String getMetadataOrDefault(
      java.lang.String key,
      java.lang.String defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.String> map =
        internalGetMetadata().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   * <pre>
   * Metadata associated with the entity.
   * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
   * available. The associated keys are "wikipedia_url" and "mid", respectively.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 3;</code>
   */

  public java.lang.String getMetadataOrThrow(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.String> map =
        internalGetMetadata().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }

  public static final int SALIENCE_FIELD_NUMBER = 4;
  private float salience_;
  /**
   * <pre>
   * The salience score associated with the entity in the [0, 1.0] range.
   * The salience score for an entity provides information about the
   * importance or centrality of that entity to the entire document text.
   * Scores closer to 0 are less salient, while scores closer to 1.0 are highly
   * salient.
   * </pre>
   *
   * <code>float salience = 4;</code>
   */
  public float getSalience() {
    return salience_;
  }

  public static final int MENTIONS_FIELD_NUMBER = 5;
  private java.util.List<com.google.cloud.language.v1.EntityMention> mentions_;
  /**
   * <pre>
   * The mentions of this entity in the input document. The API currently
   * supports proper noun mentions.
   * </pre>
   *
   * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
   */
  public java.util.List<com.google.cloud.language.v1.EntityMention> getMentionsList() {
    return mentions_;
  }
  /**
   * <pre>
   * The mentions of this entity in the input document. The API currently
   * supports proper noun mentions.
   * </pre>
   *
   * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
   */
  public java.util.List<? extends com.google.cloud.language.v1.EntityMentionOrBuilder> 
      getMentionsOrBuilderList() {
    return mentions_;
  }
  /**
   * <pre>
   * The mentions of this entity in the input document. The API currently
   * supports proper noun mentions.
   * </pre>
   *
   * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
   */
  public int getMentionsCount() {
    return mentions_.size();
  }
  /**
   * <pre>
   * The mentions of this entity in the input document. The API currently
   * supports proper noun mentions.
   * </pre>
   *
   * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
   */
  public com.google.cloud.language.v1.EntityMention getMentions(int index) {
    return mentions_.get(index);
  }
  /**
   * <pre>
   * The mentions of this entity in the input document. The API currently
   * supports proper noun mentions.
   * </pre>
   *
   * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
   */
  public com.google.cloud.language.v1.EntityMentionOrBuilder getMentionsOrBuilder(
      int index) {
    return mentions_.get(index);
  }

  public static final int SENTIMENT_FIELD_NUMBER = 6;
  private com.google.cloud.language.v1.Sentiment sentiment_;
  /**
   * <pre>
   * For calls to [AnalyzeEntitySentiment][] or if
   * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
   * true, this field will contain the aggregate sentiment expressed for this
   * entity in the provided document.
   * </pre>
   *
   * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
   */
  public boolean hasSentiment() {
    return sentiment_ != null;
  }
  /**
   * <pre>
   * For calls to [AnalyzeEntitySentiment][] or if
   * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
   * true, this field will contain the aggregate sentiment expressed for this
   * entity in the provided document.
   * </pre>
   *
   * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
   */
  public com.google.cloud.language.v1.Sentiment getSentiment() {
    return sentiment_ == null ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() : sentiment_;
  }
  /**
   * <pre>
   * For calls to [AnalyzeEntitySentiment][] or if
   * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
   * true, this field will contain the aggregate sentiment expressed for this
   * entity in the provided document.
   * </pre>
   *
   * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
   */
  public com.google.cloud.language.v1.SentimentOrBuilder getSentimentOrBuilder() {
    return getSentiment();
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (!getNameBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
    }
    if (type_ != com.google.cloud.language.v1.Entity.Type.UNKNOWN.getNumber()) {
      output.writeEnum(2, type_);
    }
    com.google.protobuf.GeneratedMessageV3
      .serializeStringMapTo(
        output,
        internalGetMetadata(),
        MetadataDefaultEntryHolder.defaultEntry,
        3);
    if (salience_ != 0F) {
      output.writeFloat(4, salience_);
    }
    for (int i = 0; i < mentions_.size(); i++) {
      output.writeMessage(5, mentions_.get(i));
    }
    if (sentiment_ != null) {
      output.writeMessage(6, getSentiment());
    }
    unknownFields.writeTo(output);
  }

  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!getNameBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
    }
    if (type_ != com.google.cloud.language.v1.Entity.Type.UNKNOWN.getNumber()) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(2, type_);
    }
    for (java.util.Map.Entry<java.lang.String, java.lang.String> entry
         : internalGetMetadata().getMap().entrySet()) {
      com.google.protobuf.MapEntry<java.lang.String, java.lang.String>
      metadata__ = MetadataDefaultEntryHolder.defaultEntry.newBuilderForType()
          .setKey(entry.getKey())
          .setValue(entry.getValue())
          .build();
      size += com.google.protobuf.CodedOutputStream
          .computeMessageSize(3, metadata__);
    }
    if (salience_ != 0F) {
      size += com.google.protobuf.CodedOutputStream
        .computeFloatSize(4, salience_);
    }
    for (int i = 0; i < mentions_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(5, mentions_.get(i));
    }
    if (sentiment_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(6, getSentiment());
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.cloud.language.v1.Entity)) {
      return super.equals(obj);
    }
    com.google.cloud.language.v1.Entity other = (com.google.cloud.language.v1.Entity) obj;

    boolean result = true;
    result = result && getName()
        .equals(other.getName());
    result = result && type_ == other.type_;
    result = result && internalGetMetadata().equals(
        other.internalGetMetadata());
    result = result && (
        java.lang.Float.floatToIntBits(getSalience())
        == java.lang.Float.floatToIntBits(
            other.getSalience()));
    result = result && getMentionsList()
        .equals(other.getMentionsList());
    result = result && (hasSentiment() == other.hasSentiment());
    if (hasSentiment()) {
      result = result && getSentiment()
          .equals(other.getSentiment());
    }
    result = result && unknownFields.equals(other.unknownFields);
    return result;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + NAME_FIELD_NUMBER;
    hash = (53 * hash) + getName().hashCode();
    hash = (37 * hash) + TYPE_FIELD_NUMBER;
    hash = (53 * hash) + type_;
    if (!internalGetMetadata().getMap().isEmpty()) {
      hash = (37 * hash) + METADATA_FIELD_NUMBER;
      hash = (53 * hash) + internalGetMetadata().hashCode();
    }
    hash = (37 * hash) + SALIENCE_FIELD_NUMBER;
    hash = (53 * hash) + java.lang.Float.floatToIntBits(
        getSalience());
    if (getMentionsCount() > 0) {
      hash = (37 * hash) + MENTIONS_FIELD_NUMBER;
      hash = (53 * hash) + getMentionsList().hashCode();
    }
    if (hasSentiment()) {
      hash = (37 * hash) + SENTIMENT_FIELD_NUMBER;
      hash = (53 * hash) + getSentiment().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.language.v1.Entity parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.cloud.language.v1.Entity parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.cloud.language.v1.Entity parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.cloud.language.v1.Entity parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.google.cloud.language.v1.Entity prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * <pre>
   * Represents a phrase in the text that is a known entity, such as
   * a person, an organization, or location. The API associates information, such
   * as salience and mentions, with entities.
   * </pre>
   *
   * Protobuf type {@code google.cloud.language.v1.Entity}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.cloud.language.v1.Entity)
      com.google.cloud.language.v1.EntityOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_descriptor;
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMapField(
        int number) {
      switch (number) {
        case 3:
          return internalGetMetadata();
        default:
          throw new RuntimeException(
              "Invalid map field number: " + number);
      }
    }
    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMutableMapField(
        int number) {
      switch (number) {
        case 3:
          return internalGetMutableMetadata();
        default:
          throw new RuntimeException(
              "Invalid map field number: " + number);
      }
    }
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.language.v1.Entity.class, com.google.cloud.language.v1.Entity.Builder.class);
    }

    // Construct using com.google.cloud.language.v1.Entity.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getMentionsFieldBuilder();
      }
    }
    public Builder clear() {
      super.clear();
      name_ = "";

      type_ = 0;

      internalGetMutableMetadata().clear();
      salience_ = 0F;

      if (mentionsBuilder_ == null) {
        mentions_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000010);
      } else {
        mentionsBuilder_.clear();
      }
      if (sentimentBuilder_ == null) {
        sentiment_ = null;
      } else {
        sentiment_ = null;
        sentimentBuilder_ = null;
      }
      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.cloud.language.v1.LanguageServiceProto.internal_static_google_cloud_language_v1_Entity_descriptor;
    }

    public com.google.cloud.language.v1.Entity getDefaultInstanceForType() {
      return com.google.cloud.language.v1.Entity.getDefaultInstance();
    }

    public com.google.cloud.language.v1.Entity build() {
      com.google.cloud.language.v1.Entity result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.cloud.language.v1.Entity buildPartial() {
      com.google.cloud.language.v1.Entity result = new com.google.cloud.language.v1.Entity(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      result.name_ = name_;
      result.type_ = type_;
      result.metadata_ = internalGetMetadata();
      result.metadata_.makeImmutable();
      result.salience_ = salience_;
      if (mentionsBuilder_ == null) {
        if (((bitField0_ & 0x00000010) == 0x00000010)) {
          mentions_ = java.util.Collections.unmodifiableList(mentions_);
          bitField0_ = (bitField0_ & ~0x00000010);
        }
        result.mentions_ = mentions_;
      } else {
        result.mentions_ = mentionsBuilder_.build();
      }
      if (sentimentBuilder_ == null) {
        result.sentiment_ = sentiment_;
      } else {
        result.sentiment_ = sentimentBuilder_.build();
      }
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    public Builder clone() {
      return (Builder) super.clone();
    }
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return (Builder) super.setField(field, value);
    }
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return (Builder) super.clearField(field);
    }
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return (Builder) super.clearOneof(oneof);
    }
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return (Builder) super.setRepeatedField(field, index, value);
    }
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return (Builder) super.addRepeatedField(field, value);
    }
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.language.v1.Entity) {
        return mergeFrom((com.google.cloud.language.v1.Entity)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.language.v1.Entity other) {
      if (other == com.google.cloud.language.v1.Entity.getDefaultInstance()) return this;
      if (!other.getName().isEmpty()) {
        name_ = other.name_;
        onChanged();
      }
      if (other.type_ != 0) {
        setTypeValue(other.getTypeValue());
      }
      internalGetMutableMetadata().mergeFrom(
          other.internalGetMetadata());
      if (other.getSalience() != 0F) {
        setSalience(other.getSalience());
      }
      if (mentionsBuilder_ == null) {
        if (!other.mentions_.isEmpty()) {
          if (mentions_.isEmpty()) {
            mentions_ = other.mentions_;
            bitField0_ = (bitField0_ & ~0x00000010);
          } else {
            ensureMentionsIsMutable();
            mentions_.addAll(other.mentions_);
          }
          onChanged();
        }
      } else {
        if (!other.mentions_.isEmpty()) {
          if (mentionsBuilder_.isEmpty()) {
            mentionsBuilder_.dispose();
            mentionsBuilder_ = null;
            mentions_ = other.mentions_;
            bitField0_ = (bitField0_ & ~0x00000010);
            mentionsBuilder_ = 
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getMentionsFieldBuilder() : null;
          } else {
            mentionsBuilder_.addAllMessages(other.mentions_);
          }
        }
      }
      if (other.hasSentiment()) {
        mergeSentiment(other.getSentiment());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

    public final boolean isInitialized() {
      return true;
    }

    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.google.cloud.language.v1.Entity parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.cloud.language.v1.Entity) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private java.lang.Object name_ = "";
    /**
     * <pre>
     * The representative name for the entity.
     * </pre>
     *
     * <code>string name = 1;</code>
     */
    public java.lang.String getName() {
      java.lang.Object ref = name_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        name_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <pre>
     * The representative name for the entity.
     * </pre>
     *
     * <code>string name = 1;</code>
     */
    public com.google.protobuf.ByteString
        getNameBytes() {
      java.lang.Object ref = name_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        name_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <pre>
     * The representative name for the entity.
     * </pre>
     *
     * <code>string name = 1;</code>
     */
    public Builder setName(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }
  
      name_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * The representative name for the entity.
     * </pre>
     *
     * <code>string name = 1;</code>
     */
    public Builder clearName() {
      
      name_ = getDefaultInstance().getName();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * The representative name for the entity.
     * </pre>
     *
     * <code>string name = 1;</code>
     */
    public Builder setNameBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);
      
      name_ = value;
      onChanged();
      return this;
    }

    private int type_ = 0;
    /**
     * <pre>
     * The entity type.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
     */
    public int getTypeValue() {
      return type_;
    }
    /**
     * <pre>
     * The entity type.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
     */
    public Builder setTypeValue(int value) {
      type_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * The entity type.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
     */
    public com.google.cloud.language.v1.Entity.Type getType() {
      com.google.cloud.language.v1.Entity.Type result = com.google.cloud.language.v1.Entity.Type.valueOf(type_);
      return result == null ? com.google.cloud.language.v1.Entity.Type.UNRECOGNIZED : result;
    }
    /**
     * <pre>
     * The entity type.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
     */
    public Builder setType(com.google.cloud.language.v1.Entity.Type value) {
      if (value == null) {
        throw new NullPointerException();
      }
      
      type_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * The entity type.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Entity.Type type = 2;</code>
     */
    public Builder clearType() {
      
      type_ = 0;
      onChanged();
      return this;
    }

    private com.google.protobuf.MapField<
        java.lang.String, java.lang.String> metadata_;
    private com.google.protobuf.MapField<java.lang.String, java.lang.String>
    internalGetMetadata() {
      if (metadata_ == null) {
        return com.google.protobuf.MapField.emptyMapField(
            MetadataDefaultEntryHolder.defaultEntry);
      }
      return metadata_;
    }
    private com.google.protobuf.MapField<java.lang.String, java.lang.String>
    internalGetMutableMetadata() {
      onChanged();;
      if (metadata_ == null) {
        metadata_ = com.google.protobuf.MapField.newMapField(
            MetadataDefaultEntryHolder.defaultEntry);
      }
      if (!metadata_.isMutable()) {
        metadata_ = metadata_.copy();
      }
      return metadata_;
    }

    public int getMetadataCount() {
      return internalGetMetadata().getMap().size();
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public boolean containsMetadata(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      return internalGetMetadata().getMap().containsKey(key);
    }
    /**
     * Use {@link #getMetadataMap()} instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
      return getMetadataMap();
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
      return internalGetMetadata().getMap();
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public java.lang.String getMetadataOrDefault(
        java.lang.String key,
        java.lang.String defaultValue) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.String> map =
          internalGetMetadata().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public java.lang.String getMetadataOrThrow(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      java.util.Map<java.lang.String, java.lang.String> map =
          internalGetMetadata().getMap();
      if (!map.containsKey(key)) {
        throw new java.lang.IllegalArgumentException();
      }
      return map.get(key);
    }

    public Builder clearMetadata() {
      internalGetMutableMetadata().getMutableMap()
          .clear();
      return this;
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public Builder removeMetadata(
        java.lang.String key) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      internalGetMutableMetadata().getMutableMap()
          .remove(key);
      return this;
    }
    /**
     * Use alternate mutation accessors instead.
     */
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.String>
    getMutableMetadata() {
      return internalGetMutableMetadata().getMutableMap();
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */
    public Builder putMetadata(
        java.lang.String key,
        java.lang.String value) {
      if (key == null) { throw new java.lang.NullPointerException(); }
      if (value == null) { throw new java.lang.NullPointerException(); }
      internalGetMutableMetadata().getMutableMap()
          .put(key, value);
      return this;
    }
    /**
     * <pre>
     * Metadata associated with the entity.
     * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
     * available. The associated keys are "wikipedia_url" and "mid", respectively.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 3;</code>
     */

    public Builder putAllMetadata(
        java.util.Map<java.lang.String, java.lang.String> values) {
      internalGetMutableMetadata().getMutableMap()
          .putAll(values);
      return this;
    }

    private float salience_ ;
    /**
     * <pre>
     * The salience score associated with the entity in the [0, 1.0] range.
     * The salience score for an entity provides information about the
     * importance or centrality of that entity to the entire document text.
     * Scores closer to 0 are less salient, while scores closer to 1.0 are highly
     * salient.
     * </pre>
     *
     * <code>float salience = 4;</code>
     */
    public float getSalience() {
      return salience_;
    }
    /**
     * <pre>
     * The salience score associated with the entity in the [0, 1.0] range.
     * The salience score for an entity provides information about the
     * importance or centrality of that entity to the entire document text.
     * Scores closer to 0 are less salient, while scores closer to 1.0 are highly
     * salient.
     * </pre>
     *
     * <code>float salience = 4;</code>
     */
    public Builder setSalience(float value) {
      
      salience_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * The salience score associated with the entity in the [0, 1.0] range.
     * The salience score for an entity provides information about the
     * importance or centrality of that entity to the entire document text.
     * Scores closer to 0 are less salient, while scores closer to 1.0 are highly
     * salient.
     * </pre>
     *
     * <code>float salience = 4;</code>
     */
    public Builder clearSalience() {
      
      salience_ = 0F;
      onChanged();
      return this;
    }

    private java.util.List<com.google.cloud.language.v1.EntityMention> mentions_ =
      java.util.Collections.emptyList();
    private void ensureMentionsIsMutable() {
      if (!((bitField0_ & 0x00000010) == 0x00000010)) {
        mentions_ = new java.util.ArrayList<com.google.cloud.language.v1.EntityMention>(mentions_);
        bitField0_ |= 0x00000010;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.cloud.language.v1.EntityMention, com.google.cloud.language.v1.EntityMention.Builder, com.google.cloud.language.v1.EntityMentionOrBuilder> mentionsBuilder_;

    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public java.util.List<com.google.cloud.language.v1.EntityMention> getMentionsList() {
      if (mentionsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(mentions_);
      } else {
        return mentionsBuilder_.getMessageList();
      }
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public int getMentionsCount() {
      if (mentionsBuilder_ == null) {
        return mentions_.size();
      } else {
        return mentionsBuilder_.getCount();
      }
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public com.google.cloud.language.v1.EntityMention getMentions(int index) {
      if (mentionsBuilder_ == null) {
        return mentions_.get(index);
      } else {
        return mentionsBuilder_.getMessage(index);
      }
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder setMentions(
        int index, com.google.cloud.language.v1.EntityMention value) {
      if (mentionsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureMentionsIsMutable();
        mentions_.set(index, value);
        onChanged();
      } else {
        mentionsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder setMentions(
        int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue) {
      if (mentionsBuilder_ == null) {
        ensureMentionsIsMutable();
        mentions_.set(index, builderForValue.build());
        onChanged();
      } else {
        mentionsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder addMentions(com.google.cloud.language.v1.EntityMention value) {
      if (mentionsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureMentionsIsMutable();
        mentions_.add(value);
        onChanged();
      } else {
        mentionsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder addMentions(
        int index, com.google.cloud.language.v1.EntityMention value) {
      if (mentionsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureMentionsIsMutable();
        mentions_.add(index, value);
        onChanged();
      } else {
        mentionsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder addMentions(
        com.google.cloud.language.v1.EntityMention.Builder builderForValue) {
      if (mentionsBuilder_ == null) {
        ensureMentionsIsMutable();
        mentions_.add(builderForValue.build());
        onChanged();
      } else {
        mentionsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder addMentions(
        int index, com.google.cloud.language.v1.EntityMention.Builder builderForValue) {
      if (mentionsBuilder_ == null) {
        ensureMentionsIsMutable();
        mentions_.add(index, builderForValue.build());
        onChanged();
      } else {
        mentionsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder addAllMentions(
        java.lang.Iterable<? extends com.google.cloud.language.v1.EntityMention> values) {
      if (mentionsBuilder_ == null) {
        ensureMentionsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, mentions_);
        onChanged();
      } else {
        mentionsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder clearMentions() {
      if (mentionsBuilder_ == null) {
        mentions_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000010);
        onChanged();
      } else {
        mentionsBuilder_.clear();
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public Builder removeMentions(int index) {
      if (mentionsBuilder_ == null) {
        ensureMentionsIsMutable();
        mentions_.remove(index);
        onChanged();
      } else {
        mentionsBuilder_.remove(index);
      }
      return this;
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public com.google.cloud.language.v1.EntityMention.Builder getMentionsBuilder(
        int index) {
      return getMentionsFieldBuilder().getBuilder(index);
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public com.google.cloud.language.v1.EntityMentionOrBuilder getMentionsOrBuilder(
        int index) {
      if (mentionsBuilder_ == null) {
        return mentions_.get(index);  } else {
        return mentionsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public java.util.List<? extends com.google.cloud.language.v1.EntityMentionOrBuilder> 
         getMentionsOrBuilderList() {
      if (mentionsBuilder_ != null) {
        return mentionsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(mentions_);
      }
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public com.google.cloud.language.v1.EntityMention.Builder addMentionsBuilder() {
      return getMentionsFieldBuilder().addBuilder(
          com.google.cloud.language.v1.EntityMention.getDefaultInstance());
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public com.google.cloud.language.v1.EntityMention.Builder addMentionsBuilder(
        int index) {
      return getMentionsFieldBuilder().addBuilder(
          index, com.google.cloud.language.v1.EntityMention.getDefaultInstance());
    }
    /**
     * <pre>
     * The mentions of this entity in the input document. The API currently
     * supports proper noun mentions.
     * </pre>
     *
     * <code>repeated .google.cloud.language.v1.EntityMention mentions = 5;</code>
     */
    public java.util.List<com.google.cloud.language.v1.EntityMention.Builder> 
         getMentionsBuilderList() {
      return getMentionsFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.cloud.language.v1.EntityMention, com.google.cloud.language.v1.EntityMention.Builder, com.google.cloud.language.v1.EntityMentionOrBuilder> 
        getMentionsFieldBuilder() {
      if (mentionsBuilder_ == null) {
        mentionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.language.v1.EntityMention, com.google.cloud.language.v1.EntityMention.Builder, com.google.cloud.language.v1.EntityMentionOrBuilder>(
                mentions_,
                ((bitField0_ & 0x00000010) == 0x00000010),
                getParentForChildren(),
                isClean());
        mentions_ = null;
      }
      return mentionsBuilder_;
    }

    private com.google.cloud.language.v1.Sentiment sentiment_ = null;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.cloud.language.v1.Sentiment, com.google.cloud.language.v1.Sentiment.Builder, com.google.cloud.language.v1.SentimentOrBuilder> sentimentBuilder_;
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public boolean hasSentiment() {
      return sentimentBuilder_ != null || sentiment_ != null;
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public com.google.cloud.language.v1.Sentiment getSentiment() {
      if (sentimentBuilder_ == null) {
        return sentiment_ == null ? com.google.cloud.language.v1.Sentiment.getDefaultInstance() : sentiment_;
      } else {
        return sentimentBuilder_.getMessage();
      }
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public Builder setSentiment(com.google.cloud.language.v1.Sentiment value) {
      if (sentimentBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        sentiment_ = value;
        onChanged();
      } else {
        sentimentBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public Builder setSentiment(
        com.google.cloud.language.v1.Sentiment.Builder builderForValue) {
      if (sentimentBuilder_ == null) {
        sentiment_ = builderForValue.build();
        onChanged();
      } else {
        sentimentBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public Builder mergeSentiment(com.google.cloud.language.v1.Sentiment value) {
      if (sentimentBuilder_ == null) {
        if (sentiment_ != null) {
          sentiment_ =
            com.google.cloud.language.v1.Sentiment.newBuilder(sentiment_).mergeFrom(value).buildPartial();
        } else {
          sentiment_ = value;
        }
        onChanged();
      } else {
        sentimentBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public Builder clearSentiment() {
      if (sentimentBuilder_ == null) {
        sentiment_ = null;
        onChanged();
      } else {
        sentiment_ = null;
        sentimentBuilder_ = null;
      }

      return this;
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public com.google.cloud.language.v1.Sentiment.Builder getSentimentBuilder() {
      
      onChanged();
      return getSentimentFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    public com.google.cloud.language.v1.SentimentOrBuilder getSentimentOrBuilder() {
      if (sentimentBuilder_ != null) {
        return sentimentBuilder_.getMessageOrBuilder();
      } else {
        return sentiment_ == null ?
            com.google.cloud.language.v1.Sentiment.getDefaultInstance() : sentiment_;
      }
    }
    /**
     * <pre>
     * For calls to [AnalyzeEntitySentiment][] or if
     * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] is set to
     * true, this field will contain the aggregate sentiment expressed for this
     * entity in the provided document.
     * </pre>
     *
     * <code>.google.cloud.language.v1.Sentiment sentiment = 6;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.cloud.language.v1.Sentiment, com.google.cloud.language.v1.Sentiment.Builder, com.google.cloud.language.v1.SentimentOrBuilder> 
        getSentimentFieldBuilder() {
      if (sentimentBuilder_ == null) {
        sentimentBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.language.v1.Sentiment, com.google.cloud.language.v1.Sentiment.Builder, com.google.cloud.language.v1.SentimentOrBuilder>(
                getSentiment(),
                getParentForChildren(),
                isClean());
        sentiment_ = null;
      }
      return sentimentBuilder_;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFieldsProto3(unknownFields);
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }


    // @@protoc_insertion_point(builder_scope:google.cloud.language.v1.Entity)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.language.v1.Entity)
  private static final com.google.cloud.language.v1.Entity DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.cloud.language.v1.Entity();
  }

  public static com.google.cloud.language.v1.Entity getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<Entity>
      PARSER = new com.google.protobuf.AbstractParser<Entity>() {
    public Entity parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return new Entity(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<Entity> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<Entity> getParserForType() {
    return PARSER;
  }

  public com.google.cloud.language.v1.Entity getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

