/*
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/automl/v1beta1/prediction_service.proto

package com.google.cloud.automl.v1beta1;

/**
 *
 *
 * <pre>
 * Response message for [PredictionService.Predict][google.cloud.automl.v1beta1.PredictionService.Predict].
 * </pre>
 *
 * Protobuf type {@code google.cloud.automl.v1beta1.PredictResponse}
 */
public final class PredictResponse extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.automl.v1beta1.PredictResponse)
    PredictResponseOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use PredictResponse.newBuilder() to construct.
  private PredictResponse(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private PredictResponse() {
    payload_ = java.util.Collections.emptyList();
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new PredictResponse();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.automl.v1beta1.PredictionServiceProto
        .internal_static_google_cloud_automl_v1beta1_PredictResponse_descriptor;
  }

  @SuppressWarnings({"rawtypes"})
  @java.lang.Override
  protected com.google.protobuf.MapField internalGetMapField(int number) {
    switch (number) {
      case 2:
        return internalGetMetadata();
      default:
        throw new RuntimeException("Invalid map field number: " + number);
    }
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.automl.v1beta1.PredictionServiceProto
        .internal_static_google_cloud_automl_v1beta1_PredictResponse_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.automl.v1beta1.PredictResponse.class,
            com.google.cloud.automl.v1beta1.PredictResponse.Builder.class);
  }

  public static final int PAYLOAD_FIELD_NUMBER = 1;

  @SuppressWarnings("serial")
  private java.util.List<com.google.cloud.automl.v1beta1.AnnotationPayload> payload_;
  /**
   *
   *
   * <pre>
   * Prediction result.
   * Translation and Text Sentiment will return precisely one payload.
   * </pre>
   *
   * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
   */
  @java.lang.Override
  public java.util.List<com.google.cloud.automl.v1beta1.AnnotationPayload> getPayloadList() {
    return payload_;
  }
  /**
   *
   *
   * <pre>
   * Prediction result.
   * Translation and Text Sentiment will return precisely one payload.
   * </pre>
   *
   * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
   */
  @java.lang.Override
  public java.util.List<? extends com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder>
      getPayloadOrBuilderList() {
    return payload_;
  }
  /**
   *
   *
   * <pre>
   * Prediction result.
   * Translation and Text Sentiment will return precisely one payload.
   * </pre>
   *
   * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
   */
  @java.lang.Override
  public int getPayloadCount() {
    return payload_.size();
  }
  /**
   *
   *
   * <pre>
   * Prediction result.
   * Translation and Text Sentiment will return precisely one payload.
   * </pre>
   *
   * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
   */
  @java.lang.Override
  public com.google.cloud.automl.v1beta1.AnnotationPayload getPayload(int index) {
    return payload_.get(index);
  }
  /**
   *
   *
   * <pre>
   * Prediction result.
   * Translation and Text Sentiment will return precisely one payload.
   * </pre>
   *
   * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
   */
  @java.lang.Override
  public com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder getPayloadOrBuilder(int index) {
    return payload_.get(index);
  }

  public static final int PREPROCESSED_INPUT_FIELD_NUMBER = 3;
  private com.google.cloud.automl.v1beta1.ExamplePayload preprocessedInput_;
  /**
   *
   *
   * <pre>
   * The preprocessed example that AutoML actually makes prediction on.
   * Empty if AutoML does not preprocess the input example.
   * * For Text Extraction:
   *   If the input is a .pdf file, the OCR'ed text will be provided in
   *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
   * </pre>
   *
   * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
   *
   * @return Whether the preprocessedInput field is set.
   */
  @java.lang.Override
  public boolean hasPreprocessedInput() {
    return preprocessedInput_ != null;
  }
  /**
   *
   *
   * <pre>
   * The preprocessed example that AutoML actually makes prediction on.
   * Empty if AutoML does not preprocess the input example.
   * * For Text Extraction:
   *   If the input is a .pdf file, the OCR'ed text will be provided in
   *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
   * </pre>
   *
   * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
   *
   * @return The preprocessedInput.
   */
  @java.lang.Override
  public com.google.cloud.automl.v1beta1.ExamplePayload getPreprocessedInput() {
    return preprocessedInput_ == null
        ? com.google.cloud.automl.v1beta1.ExamplePayload.getDefaultInstance()
        : preprocessedInput_;
  }
  /**
   *
   *
   * <pre>
   * The preprocessed example that AutoML actually makes prediction on.
   * Empty if AutoML does not preprocess the input example.
   * * For Text Extraction:
   *   If the input is a .pdf file, the OCR'ed text will be provided in
   *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
   * </pre>
   *
   * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
   */
  @java.lang.Override
  public com.google.cloud.automl.v1beta1.ExamplePayloadOrBuilder getPreprocessedInputOrBuilder() {
    return preprocessedInput_ == null
        ? com.google.cloud.automl.v1beta1.ExamplePayload.getDefaultInstance()
        : preprocessedInput_;
  }

  public static final int METADATA_FIELD_NUMBER = 2;

  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.automl.v1beta1.PredictionServiceProto
                .internal_static_google_cloud_automl_v1beta1_PredictResponse_MetadataEntry_descriptor,
            com.google.protobuf.WireFormat.FieldType.STRING,
            "",
            com.google.protobuf.WireFormat.FieldType.STRING,
            "");
  }

  @SuppressWarnings("serial")
  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>
   * Additional domain-specific prediction response metadata.
   * * For Image Object Detection:
   *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
   *      image could have been returned.
   * * For Text Sentiment:
   *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
   *      -1 maps to least positive sentiment, while 1 maps to the most positive
   *      one and the higher the score, the more positive the sentiment in the
   *      document is. Yet these values are relative to the training data, so
   *      e.g. if all data was positive then -1 will be also positive (though
   *      the least).
   *      The sentiment_score shouldn't be confused with "score" or "magnitude"
   *      from the previous Natural Language Sentiment Analysis API.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 2;</code>
   */
  @java.lang.Override
  public boolean containsMetadata(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    return internalGetMetadata().getMap().containsKey(key);
  }
  /** Use {@link #getMetadataMap()} instead. */
  @java.lang.Override
  @java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
    return getMetadataMap();
  }
  /**
   *
   *
   * <pre>
   * Additional domain-specific prediction response metadata.
   * * For Image Object Detection:
   *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
   *      image could have been returned.
   * * For Text Sentiment:
   *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
   *      -1 maps to least positive sentiment, while 1 maps to the most positive
   *      one and the higher the score, the more positive the sentiment in the
   *      document is. Yet these values are relative to the training data, so
   *      e.g. if all data was positive then -1 will be also positive (though
   *      the least).
   *      The sentiment_score shouldn't be confused with "score" or "magnitude"
   *      from the previous Natural Language Sentiment Analysis API.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 2;</code>
   */
  @java.lang.Override
  public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
    return internalGetMetadata().getMap();
  }
  /**
   *
   *
   * <pre>
   * Additional domain-specific prediction response metadata.
   * * For Image Object Detection:
   *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
   *      image could have been returned.
   * * For Text Sentiment:
   *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
   *      -1 maps to least positive sentiment, while 1 maps to the most positive
   *      one and the higher the score, the more positive the sentiment in the
   *      document is. Yet these values are relative to the training data, so
   *      e.g. if all data was positive then -1 will be also positive (though
   *      the least).
   *      The sentiment_score shouldn't be confused with "score" or "magnitude"
   *      from the previous Natural Language Sentiment Analysis API.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 2;</code>
   */
  @java.lang.Override
  public /* nullable */ java.lang.String getMetadataOrDefault(
      java.lang.String key,
      /* nullable */
      java.lang.String defaultValue) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
  /**
   *
   *
   * <pre>
   * Additional domain-specific prediction response metadata.
   * * For Image Object Detection:
   *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
   *      image could have been returned.
   * * For Text Sentiment:
   *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
   *      -1 maps to least positive sentiment, while 1 maps to the most positive
   *      one and the higher the score, the more positive the sentiment in the
   *      document is. Yet these values are relative to the training data, so
   *      e.g. if all data was positive then -1 will be also positive (though
   *      the least).
   *      The sentiment_score shouldn't be confused with "score" or "magnitude"
   *      from the previous Natural Language Sentiment Analysis API.
   * </pre>
   *
   * <code>map&lt;string, string&gt; metadata = 2;</code>
   */
  @java.lang.Override
  public java.lang.String getMetadataOrThrow(java.lang.String key) {
    if (key == null) {
      throw new NullPointerException("map key");
    }
    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);
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    for (int i = 0; i < payload_.size(); i++) {
      output.writeMessage(1, payload_.get(i));
    }
    com.google.protobuf.GeneratedMessageV3.serializeStringMapTo(
        output, internalGetMetadata(), MetadataDefaultEntryHolder.defaultEntry, 2);
    if (preprocessedInput_ != null) {
      output.writeMessage(3, getPreprocessedInput());
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    for (int i = 0; i < payload_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, payload_.get(i));
    }
    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(2, metadata__);
    }
    if (preprocessedInput_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getPreprocessedInput());
    }
    size += getUnknownFields().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.automl.v1beta1.PredictResponse)) {
      return super.equals(obj);
    }
    com.google.cloud.automl.v1beta1.PredictResponse other =
        (com.google.cloud.automl.v1beta1.PredictResponse) obj;

    if (!getPayloadList().equals(other.getPayloadList())) return false;
    if (hasPreprocessedInput() != other.hasPreprocessedInput()) return false;
    if (hasPreprocessedInput()) {
      if (!getPreprocessedInput().equals(other.getPreprocessedInput())) return false;
    }
    if (!internalGetMetadata().equals(other.internalGetMetadata())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getPayloadCount() > 0) {
      hash = (37 * hash) + PAYLOAD_FIELD_NUMBER;
      hash = (53 * hash) + getPayloadList().hashCode();
    }
    if (hasPreprocessedInput()) {
      hash = (37 * hash) + PREPROCESSED_INPUT_FIELD_NUMBER;
      hash = (53 * hash) + getPreprocessedInput().hashCode();
    }
    if (!internalGetMetadata().getMap().isEmpty()) {
      hash = (37 * hash) + METADATA_FIELD_NUMBER;
      hash = (53 * hash) + internalGetMetadata().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse 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.automl.v1beta1.PredictResponse parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse 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.automl.v1beta1.PredictResponse parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse 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.automl.v1beta1.PredictResponse parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse 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.automl.v1beta1.PredictResponse parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.cloud.automl.v1beta1.PredictResponse prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  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>
   * Response message for [PredictionService.Predict][google.cloud.automl.v1beta1.PredictionService.Predict].
   * </pre>
   *
   * Protobuf type {@code google.cloud.automl.v1beta1.PredictResponse}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.automl.v1beta1.PredictResponse)
      com.google.cloud.automl.v1beta1.PredictResponseOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.automl.v1beta1.PredictionServiceProto
          .internal_static_google_cloud_automl_v1beta1_PredictResponse_descriptor;
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMapField(int number) {
      switch (number) {
        case 2:
          return internalGetMetadata();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @SuppressWarnings({"rawtypes"})
    protected com.google.protobuf.MapField internalGetMutableMapField(int number) {
      switch (number) {
        case 2:
          return internalGetMutableMetadata();
        default:
          throw new RuntimeException("Invalid map field number: " + number);
      }
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.automl.v1beta1.PredictionServiceProto
          .internal_static_google_cloud_automl_v1beta1_PredictResponse_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.automl.v1beta1.PredictResponse.class,
              com.google.cloud.automl.v1beta1.PredictResponse.Builder.class);
    }

    // Construct using com.google.cloud.automl.v1beta1.PredictResponse.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      if (payloadBuilder_ == null) {
        payload_ = java.util.Collections.emptyList();
      } else {
        payload_ = null;
        payloadBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000001);
      preprocessedInput_ = null;
      if (preprocessedInputBuilder_ != null) {
        preprocessedInputBuilder_.dispose();
        preprocessedInputBuilder_ = null;
      }
      internalGetMutableMetadata().clear();
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.automl.v1beta1.PredictionServiceProto
          .internal_static_google_cloud_automl_v1beta1_PredictResponse_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.automl.v1beta1.PredictResponse getDefaultInstanceForType() {
      return com.google.cloud.automl.v1beta1.PredictResponse.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.automl.v1beta1.PredictResponse build() {
      com.google.cloud.automl.v1beta1.PredictResponse result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.automl.v1beta1.PredictResponse buildPartial() {
      com.google.cloud.automl.v1beta1.PredictResponse result =
          new com.google.cloud.automl.v1beta1.PredictResponse(this);
      buildPartialRepeatedFields(result);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartialRepeatedFields(
        com.google.cloud.automl.v1beta1.PredictResponse result) {
      if (payloadBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)) {
          payload_ = java.util.Collections.unmodifiableList(payload_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.payload_ = payload_;
      } else {
        result.payload_ = payloadBuilder_.build();
      }
    }

    private void buildPartial0(com.google.cloud.automl.v1beta1.PredictResponse result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.preprocessedInput_ =
            preprocessedInputBuilder_ == null
                ? preprocessedInput_
                : preprocessedInputBuilder_.build();
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.metadata_ = internalGetMetadata();
        result.metadata_.makeImmutable();
      }
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.automl.v1beta1.PredictResponse) {
        return mergeFrom((com.google.cloud.automl.v1beta1.PredictResponse) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.automl.v1beta1.PredictResponse other) {
      if (other == com.google.cloud.automl.v1beta1.PredictResponse.getDefaultInstance())
        return this;
      if (payloadBuilder_ == null) {
        if (!other.payload_.isEmpty()) {
          if (payload_.isEmpty()) {
            payload_ = other.payload_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensurePayloadIsMutable();
            payload_.addAll(other.payload_);
          }
          onChanged();
        }
      } else {
        if (!other.payload_.isEmpty()) {
          if (payloadBuilder_.isEmpty()) {
            payloadBuilder_.dispose();
            payloadBuilder_ = null;
            payload_ = other.payload_;
            bitField0_ = (bitField0_ & ~0x00000001);
            payloadBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getPayloadFieldBuilder()
                    : null;
          } else {
            payloadBuilder_.addAllMessages(other.payload_);
          }
        }
      }
      if (other.hasPreprocessedInput()) {
        mergePreprocessedInput(other.getPreprocessedInput());
      }
      internalGetMutableMetadata().mergeFrom(other.internalGetMetadata());
      bitField0_ |= 0x00000004;
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                com.google.cloud.automl.v1beta1.AnnotationPayload m =
                    input.readMessage(
                        com.google.cloud.automl.v1beta1.AnnotationPayload.parser(),
                        extensionRegistry);
                if (payloadBuilder_ == null) {
                  ensurePayloadIsMutable();
                  payload_.add(m);
                } else {
                  payloadBuilder_.addMessage(m);
                }
                break;
              } // case 10
            case 18:
              {
                com.google.protobuf.MapEntry<java.lang.String, java.lang.String> metadata__ =
                    input.readMessage(
                        MetadataDefaultEntryHolder.defaultEntry.getParserForType(),
                        extensionRegistry);
                internalGetMutableMetadata()
                    .getMutableMap()
                    .put(metadata__.getKey(), metadata__.getValue());
                bitField0_ |= 0x00000004;
                break;
              } // case 18
            case 26:
              {
                input.readMessage(
                    getPreprocessedInputFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000002;
                break;
              } // case 26
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.util.List<com.google.cloud.automl.v1beta1.AnnotationPayload> payload_ =
        java.util.Collections.emptyList();

    private void ensurePayloadIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        payload_ =
            new java.util.ArrayList<com.google.cloud.automl.v1beta1.AnnotationPayload>(payload_);
        bitField0_ |= 0x00000001;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.automl.v1beta1.AnnotationPayload,
            com.google.cloud.automl.v1beta1.AnnotationPayload.Builder,
            com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder>
        payloadBuilder_;

    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public java.util.List<com.google.cloud.automl.v1beta1.AnnotationPayload> getPayloadList() {
      if (payloadBuilder_ == null) {
        return java.util.Collections.unmodifiableList(payload_);
      } else {
        return payloadBuilder_.getMessageList();
      }
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public int getPayloadCount() {
      if (payloadBuilder_ == null) {
        return payload_.size();
      } else {
        return payloadBuilder_.getCount();
      }
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public com.google.cloud.automl.v1beta1.AnnotationPayload getPayload(int index) {
      if (payloadBuilder_ == null) {
        return payload_.get(index);
      } else {
        return payloadBuilder_.getMessage(index);
      }
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder setPayload(int index, com.google.cloud.automl.v1beta1.AnnotationPayload value) {
      if (payloadBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensurePayloadIsMutable();
        payload_.set(index, value);
        onChanged();
      } else {
        payloadBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder setPayload(
        int index, com.google.cloud.automl.v1beta1.AnnotationPayload.Builder builderForValue) {
      if (payloadBuilder_ == null) {
        ensurePayloadIsMutable();
        payload_.set(index, builderForValue.build());
        onChanged();
      } else {
        payloadBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder addPayload(com.google.cloud.automl.v1beta1.AnnotationPayload value) {
      if (payloadBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensurePayloadIsMutable();
        payload_.add(value);
        onChanged();
      } else {
        payloadBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder addPayload(int index, com.google.cloud.automl.v1beta1.AnnotationPayload value) {
      if (payloadBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensurePayloadIsMutable();
        payload_.add(index, value);
        onChanged();
      } else {
        payloadBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder addPayload(
        com.google.cloud.automl.v1beta1.AnnotationPayload.Builder builderForValue) {
      if (payloadBuilder_ == null) {
        ensurePayloadIsMutable();
        payload_.add(builderForValue.build());
        onChanged();
      } else {
        payloadBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder addPayload(
        int index, com.google.cloud.automl.v1beta1.AnnotationPayload.Builder builderForValue) {
      if (payloadBuilder_ == null) {
        ensurePayloadIsMutable();
        payload_.add(index, builderForValue.build());
        onChanged();
      } else {
        payloadBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder addAllPayload(
        java.lang.Iterable<? extends com.google.cloud.automl.v1beta1.AnnotationPayload> values) {
      if (payloadBuilder_ == null) {
        ensurePayloadIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, payload_);
        onChanged();
      } else {
        payloadBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder clearPayload() {
      if (payloadBuilder_ == null) {
        payload_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        payloadBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public Builder removePayload(int index) {
      if (payloadBuilder_ == null) {
        ensurePayloadIsMutable();
        payload_.remove(index);
        onChanged();
      } else {
        payloadBuilder_.remove(index);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public com.google.cloud.automl.v1beta1.AnnotationPayload.Builder getPayloadBuilder(int index) {
      return getPayloadFieldBuilder().getBuilder(index);
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder getPayloadOrBuilder(
        int index) {
      if (payloadBuilder_ == null) {
        return payload_.get(index);
      } else {
        return payloadBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public java.util.List<? extends com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder>
        getPayloadOrBuilderList() {
      if (payloadBuilder_ != null) {
        return payloadBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(payload_);
      }
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public com.google.cloud.automl.v1beta1.AnnotationPayload.Builder addPayloadBuilder() {
      return getPayloadFieldBuilder()
          .addBuilder(com.google.cloud.automl.v1beta1.AnnotationPayload.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public com.google.cloud.automl.v1beta1.AnnotationPayload.Builder addPayloadBuilder(int index) {
      return getPayloadFieldBuilder()
          .addBuilder(
              index, com.google.cloud.automl.v1beta1.AnnotationPayload.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * Prediction result.
     * Translation and Text Sentiment will return precisely one payload.
     * </pre>
     *
     * <code>repeated .google.cloud.automl.v1beta1.AnnotationPayload payload = 1;</code>
     */
    public java.util.List<com.google.cloud.automl.v1beta1.AnnotationPayload.Builder>
        getPayloadBuilderList() {
      return getPayloadFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.cloud.automl.v1beta1.AnnotationPayload,
            com.google.cloud.automl.v1beta1.AnnotationPayload.Builder,
            com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder>
        getPayloadFieldBuilder() {
      if (payloadBuilder_ == null) {
        payloadBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                com.google.cloud.automl.v1beta1.AnnotationPayload,
                com.google.cloud.automl.v1beta1.AnnotationPayload.Builder,
                com.google.cloud.automl.v1beta1.AnnotationPayloadOrBuilder>(
                payload_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean());
        payload_ = null;
      }
      return payloadBuilder_;
    }

    private com.google.cloud.automl.v1beta1.ExamplePayload preprocessedInput_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.automl.v1beta1.ExamplePayload,
            com.google.cloud.automl.v1beta1.ExamplePayload.Builder,
            com.google.cloud.automl.v1beta1.ExamplePayloadOrBuilder>
        preprocessedInputBuilder_;
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     *
     * @return Whether the preprocessedInput field is set.
     */
    public boolean hasPreprocessedInput() {
      return ((bitField0_ & 0x00000002) != 0);
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     *
     * @return The preprocessedInput.
     */
    public com.google.cloud.automl.v1beta1.ExamplePayload getPreprocessedInput() {
      if (preprocessedInputBuilder_ == null) {
        return preprocessedInput_ == null
            ? com.google.cloud.automl.v1beta1.ExamplePayload.getDefaultInstance()
            : preprocessedInput_;
      } else {
        return preprocessedInputBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public Builder setPreprocessedInput(com.google.cloud.automl.v1beta1.ExamplePayload value) {
      if (preprocessedInputBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        preprocessedInput_ = value;
      } else {
        preprocessedInputBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public Builder setPreprocessedInput(
        com.google.cloud.automl.v1beta1.ExamplePayload.Builder builderForValue) {
      if (preprocessedInputBuilder_ == null) {
        preprocessedInput_ = builderForValue.build();
      } else {
        preprocessedInputBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public Builder mergePreprocessedInput(com.google.cloud.automl.v1beta1.ExamplePayload value) {
      if (preprocessedInputBuilder_ == null) {
        if (((bitField0_ & 0x00000002) != 0)
            && preprocessedInput_ != null
            && preprocessedInput_
                != com.google.cloud.automl.v1beta1.ExamplePayload.getDefaultInstance()) {
          getPreprocessedInputBuilder().mergeFrom(value);
        } else {
          preprocessedInput_ = value;
        }
      } else {
        preprocessedInputBuilder_.mergeFrom(value);
      }
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public Builder clearPreprocessedInput() {
      bitField0_ = (bitField0_ & ~0x00000002);
      preprocessedInput_ = null;
      if (preprocessedInputBuilder_ != null) {
        preprocessedInputBuilder_.dispose();
        preprocessedInputBuilder_ = null;
      }
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public com.google.cloud.automl.v1beta1.ExamplePayload.Builder getPreprocessedInputBuilder() {
      bitField0_ |= 0x00000002;
      onChanged();
      return getPreprocessedInputFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    public com.google.cloud.automl.v1beta1.ExamplePayloadOrBuilder getPreprocessedInputOrBuilder() {
      if (preprocessedInputBuilder_ != null) {
        return preprocessedInputBuilder_.getMessageOrBuilder();
      } else {
        return preprocessedInput_ == null
            ? com.google.cloud.automl.v1beta1.ExamplePayload.getDefaultInstance()
            : preprocessedInput_;
      }
    }
    /**
     *
     *
     * <pre>
     * The preprocessed example that AutoML actually makes prediction on.
     * Empty if AutoML does not preprocess the input example.
     * * For Text Extraction:
     *   If the input is a .pdf file, the OCR'ed text will be provided in
     *   [document_text][google.cloud.automl.v1beta1.Document.document_text].
     * </pre>
     *
     * <code>.google.cloud.automl.v1beta1.ExamplePayload preprocessed_input = 3;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.automl.v1beta1.ExamplePayload,
            com.google.cloud.automl.v1beta1.ExamplePayload.Builder,
            com.google.cloud.automl.v1beta1.ExamplePayloadOrBuilder>
        getPreprocessedInputFieldBuilder() {
      if (preprocessedInputBuilder_ == null) {
        preprocessedInputBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.cloud.automl.v1beta1.ExamplePayload,
                com.google.cloud.automl.v1beta1.ExamplePayload.Builder,
                com.google.cloud.automl.v1beta1.ExamplePayloadOrBuilder>(
                getPreprocessedInput(), getParentForChildren(), isClean());
        preprocessedInput_ = null;
      }
      return preprocessedInputBuilder_;
    }

    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() {
      if (metadata_ == null) {
        metadata_ =
            com.google.protobuf.MapField.newMapField(MetadataDefaultEntryHolder.defaultEntry);
      }
      if (!metadata_.isMutable()) {
        metadata_ = metadata_.copy();
      }
      bitField0_ |= 0x00000004;
      onChanged();
      return metadata_;
    }

    public int getMetadataCount() {
      return internalGetMetadata().getMap().size();
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    @java.lang.Override
    public boolean containsMetadata(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      return internalGetMetadata().getMap().containsKey(key);
    }
    /** Use {@link #getMetadataMap()} instead. */
    @java.lang.Override
    @java.lang.Deprecated
    public java.util.Map<java.lang.String, java.lang.String> getMetadata() {
      return getMetadataMap();
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    @java.lang.Override
    public java.util.Map<java.lang.String, java.lang.String> getMetadataMap() {
      return internalGetMetadata().getMap();
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    @java.lang.Override
    public /* nullable */ java.lang.String getMetadataOrDefault(
        java.lang.String key,
        /* nullable */
        java.lang.String defaultValue) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      java.util.Map<java.lang.String, java.lang.String> map = internalGetMetadata().getMap();
      return map.containsKey(key) ? map.get(key) : defaultValue;
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    @java.lang.Override
    public java.lang.String getMetadataOrThrow(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      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() {
      bitField0_ = (bitField0_ & ~0x00000004);
      internalGetMutableMetadata().getMutableMap().clear();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    public Builder removeMetadata(java.lang.String key) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      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() {
      bitField0_ |= 0x00000004;
      return internalGetMutableMetadata().getMutableMap();
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    public Builder putMetadata(java.lang.String key, java.lang.String value) {
      if (key == null) {
        throw new NullPointerException("map key");
      }
      if (value == null) {
        throw new NullPointerException("map value");
      }
      internalGetMutableMetadata().getMutableMap().put(key, value);
      bitField0_ |= 0x00000004;
      return this;
    }
    /**
     *
     *
     * <pre>
     * Additional domain-specific prediction response metadata.
     * * For Image Object Detection:
     *  `max_bounding_box_count` - (int64) At most that many bounding boxes per
     *      image could have been returned.
     * * For Text Sentiment:
     *  `sentiment_score` - (float, deprecated) A value between -1 and 1,
     *      -1 maps to least positive sentiment, while 1 maps to the most positive
     *      one and the higher the score, the more positive the sentiment in the
     *      document is. Yet these values are relative to the training data, so
     *      e.g. if all data was positive then -1 will be also positive (though
     *      the least).
     *      The sentiment_score shouldn't be confused with "score" or "magnitude"
     *      from the previous Natural Language Sentiment Analysis API.
     * </pre>
     *
     * <code>map&lt;string, string&gt; metadata = 2;</code>
     */
    public Builder putAllMetadata(java.util.Map<java.lang.String, java.lang.String> values) {
      internalGetMutableMetadata().getMutableMap().putAll(values);
      bitField0_ |= 0x00000004;
      return this;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

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

    // @@protoc_insertion_point(builder_scope:google.cloud.automl.v1beta1.PredictResponse)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.automl.v1beta1.PredictResponse)
  private static final com.google.cloud.automl.v1beta1.PredictResponse DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.automl.v1beta1.PredictResponse();
  }

  public static com.google.cloud.automl.v1beta1.PredictResponse getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<PredictResponse> PARSER =
      new com.google.protobuf.AbstractParser<PredictResponse>() {
        @java.lang.Override
        public PredictResponse parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

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

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

  @java.lang.Override
  public com.google.cloud.automl.v1beta1.PredictResponse getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
