// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/spanner/v1/result_set.proto

package com.google.spanner.v1;

/**
 *
 *
 * <pre>
 * Results from [Read][google.spanner.v1.Spanner.Read] or
 * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
 * </pre>
 *
 * Protobuf type {@code google.spanner.v1.ResultSet}
 */
public final class ResultSet extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.spanner.v1.ResultSet)
    ResultSetOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use ResultSet.newBuilder() to construct.
  private ResultSet(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private ResultSet() {
    rows_ = java.util.Collections.emptyList();
  }

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

  private ResultSet(
      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;
          case 10:
            {
              com.google.spanner.v1.ResultSetMetadata.Builder subBuilder = null;
              if (metadata_ != null) {
                subBuilder = metadata_.toBuilder();
              }
              metadata_ =
                  input.readMessage(
                      com.google.spanner.v1.ResultSetMetadata.parser(), extensionRegistry);
              if (subBuilder != null) {
                subBuilder.mergeFrom(metadata_);
                metadata_ = subBuilder.buildPartial();
              }

              break;
            }
          case 18:
            {
              if (!((mutable_bitField0_ & 0x00000002) != 0)) {
                rows_ = new java.util.ArrayList<com.google.protobuf.ListValue>();
                mutable_bitField0_ |= 0x00000002;
              }
              rows_.add(
                  input.readMessage(com.google.protobuf.ListValue.parser(), extensionRegistry));
              break;
            }
          case 26:
            {
              com.google.spanner.v1.ResultSetStats.Builder subBuilder = null;
              if (stats_ != null) {
                subBuilder = stats_.toBuilder();
              }
              stats_ =
                  input.readMessage(
                      com.google.spanner.v1.ResultSetStats.parser(), extensionRegistry);
              if (subBuilder != null) {
                subBuilder.mergeFrom(stats_);
                stats_ = subBuilder.buildPartial();
              }

              break;
            }
          default:
            {
              if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
                done = true;
              }
              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_ & 0x00000002) != 0)) {
        rows_ = java.util.Collections.unmodifiableList(rows_);
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.spanner.v1.ResultSetProto
        .internal_static_google_spanner_v1_ResultSet_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.spanner.v1.ResultSetProto
        .internal_static_google_spanner_v1_ResultSet_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.spanner.v1.ResultSet.class, com.google.spanner.v1.ResultSet.Builder.class);
  }

  private int bitField0_;
  public static final int METADATA_FIELD_NUMBER = 1;
  private com.google.spanner.v1.ResultSetMetadata metadata_;
  /**
   *
   *
   * <pre>
   * Metadata about the result set, such as row type information.
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
   */
  public boolean hasMetadata() {
    return metadata_ != null;
  }
  /**
   *
   *
   * <pre>
   * Metadata about the result set, such as row type information.
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
   */
  public com.google.spanner.v1.ResultSetMetadata getMetadata() {
    return metadata_ == null
        ? com.google.spanner.v1.ResultSetMetadata.getDefaultInstance()
        : metadata_;
  }
  /**
   *
   *
   * <pre>
   * Metadata about the result set, such as row type information.
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
   */
  public com.google.spanner.v1.ResultSetMetadataOrBuilder getMetadataOrBuilder() {
    return getMetadata();
  }

  public static final int ROWS_FIELD_NUMBER = 2;
  private java.util.List<com.google.protobuf.ListValue> rows_;
  /**
   *
   *
   * <pre>
   * Each element in `rows` is a row whose format is defined by
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
   * element in each row matches the ith field in
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
   * are encoded based on type as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue rows = 2;</code>
   */
  public java.util.List<com.google.protobuf.ListValue> getRowsList() {
    return rows_;
  }
  /**
   *
   *
   * <pre>
   * Each element in `rows` is a row whose format is defined by
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
   * element in each row matches the ith field in
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
   * are encoded based on type as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue rows = 2;</code>
   */
  public java.util.List<? extends com.google.protobuf.ListValueOrBuilder> getRowsOrBuilderList() {
    return rows_;
  }
  /**
   *
   *
   * <pre>
   * Each element in `rows` is a row whose format is defined by
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
   * element in each row matches the ith field in
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
   * are encoded based on type as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue rows = 2;</code>
   */
  public int getRowsCount() {
    return rows_.size();
  }
  /**
   *
   *
   * <pre>
   * Each element in `rows` is a row whose format is defined by
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
   * element in each row matches the ith field in
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
   * are encoded based on type as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue rows = 2;</code>
   */
  public com.google.protobuf.ListValue getRows(int index) {
    return rows_.get(index);
  }
  /**
   *
   *
   * <pre>
   * Each element in `rows` is a row whose format is defined by
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
   * element in each row matches the ith field in
   * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
   * are encoded based on type as described [here][google.spanner.v1.TypeCode].
   * </pre>
   *
   * <code>repeated .google.protobuf.ListValue rows = 2;</code>
   */
  public com.google.protobuf.ListValueOrBuilder getRowsOrBuilder(int index) {
    return rows_.get(index);
  }

  public static final int STATS_FIELD_NUMBER = 3;
  private com.google.spanner.v1.ResultSetStats stats_;
  /**
   *
   *
   * <pre>
   * Query plan and execution statistics for the SQL statement that
   * produced this result set. These can be requested by setting
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * DML statements always produce stats containing the number of rows
   * modified, unless executed using the
   * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * Other fields may or may not be populated, based on the
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
   */
  public boolean hasStats() {
    return stats_ != null;
  }
  /**
   *
   *
   * <pre>
   * Query plan and execution statistics for the SQL statement that
   * produced this result set. These can be requested by setting
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * DML statements always produce stats containing the number of rows
   * modified, unless executed using the
   * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * Other fields may or may not be populated, based on the
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
   */
  public com.google.spanner.v1.ResultSetStats getStats() {
    return stats_ == null ? com.google.spanner.v1.ResultSetStats.getDefaultInstance() : stats_;
  }
  /**
   *
   *
   * <pre>
   * Query plan and execution statistics for the SQL statement that
   * produced this result set. These can be requested by setting
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * DML statements always produce stats containing the number of rows
   * modified, unless executed using the
   * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * Other fields may or may not be populated, based on the
   * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
   * </pre>
   *
   * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
   */
  public com.google.spanner.v1.ResultSetStatsOrBuilder getStatsOrBuilder() {
    return getStats();
  }

  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 {
    if (metadata_ != null) {
      output.writeMessage(1, getMetadata());
    }
    for (int i = 0; i < rows_.size(); i++) {
      output.writeMessage(2, rows_.get(i));
    }
    if (stats_ != null) {
      output.writeMessage(3, getStats());
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    if (metadata_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getMetadata());
    }
    for (int i = 0; i < rows_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, rows_.get(i));
    }
    if (stats_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getStats());
    }
    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.spanner.v1.ResultSet)) {
      return super.equals(obj);
    }
    com.google.spanner.v1.ResultSet other = (com.google.spanner.v1.ResultSet) obj;

    if (hasMetadata() != other.hasMetadata()) return false;
    if (hasMetadata()) {
      if (!getMetadata().equals(other.getMetadata())) return false;
    }
    if (!getRowsList().equals(other.getRowsList())) return false;
    if (hasStats() != other.hasStats()) return false;
    if (hasStats()) {
      if (!getStats().equals(other.getStats())) return false;
    }
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (hasMetadata()) {
      hash = (37 * hash) + METADATA_FIELD_NUMBER;
      hash = (53 * hash) + getMetadata().hashCode();
    }
    if (getRowsCount() > 0) {
      hash = (37 * hash) + ROWS_FIELD_NUMBER;
      hash = (53 * hash) + getRowsList().hashCode();
    }
    if (hasStats()) {
      hash = (37 * hash) + STATS_FIELD_NUMBER;
      hash = (53 * hash) + getStats().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.spanner.v1.ResultSet parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.spanner.v1.ResultSet parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.spanner.v1.ResultSet parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

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

  public static com.google.spanner.v1.ResultSet parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.spanner.v1.ResultSet parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

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

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

  public static com.google.spanner.v1.ResultSet 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.spanner.v1.ResultSet 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>
   * Results from [Read][google.spanner.v1.Spanner.Read] or
   * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
   * </pre>
   *
   * Protobuf type {@code google.spanner.v1.ResultSet}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.spanner.v1.ResultSet)
      com.google.spanner.v1.ResultSetOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.spanner.v1.ResultSetProto
          .internal_static_google_spanner_v1_ResultSet_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.spanner.v1.ResultSetProto
          .internal_static_google_spanner_v1_ResultSet_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.spanner.v1.ResultSet.class, com.google.spanner.v1.ResultSet.Builder.class);
    }

    // Construct using com.google.spanner.v1.ResultSet.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

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

    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
        getRowsFieldBuilder();
      }
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      if (metadataBuilder_ == null) {
        metadata_ = null;
      } else {
        metadata_ = null;
        metadataBuilder_ = null;
      }
      if (rowsBuilder_ == null) {
        rows_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
      } else {
        rowsBuilder_.clear();
      }
      if (statsBuilder_ == null) {
        stats_ = null;
      } else {
        stats_ = null;
        statsBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.spanner.v1.ResultSetProto
          .internal_static_google_spanner_v1_ResultSet_descriptor;
    }

    @java.lang.Override
    public com.google.spanner.v1.ResultSet getDefaultInstanceForType() {
      return com.google.spanner.v1.ResultSet.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.spanner.v1.ResultSet build() {
      com.google.spanner.v1.ResultSet result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.spanner.v1.ResultSet buildPartial() {
      com.google.spanner.v1.ResultSet result = new com.google.spanner.v1.ResultSet(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      if (metadataBuilder_ == null) {
        result.metadata_ = metadata_;
      } else {
        result.metadata_ = metadataBuilder_.build();
      }
      if (rowsBuilder_ == null) {
        if (((bitField0_ & 0x00000002) != 0)) {
          rows_ = java.util.Collections.unmodifiableList(rows_);
          bitField0_ = (bitField0_ & ~0x00000002);
        }
        result.rows_ = rows_;
      } else {
        result.rows_ = rowsBuilder_.build();
      }
      if (statsBuilder_ == null) {
        result.stats_ = stats_;
      } else {
        result.stats_ = statsBuilder_.build();
      }
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    @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.spanner.v1.ResultSet) {
        return mergeFrom((com.google.spanner.v1.ResultSet) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.spanner.v1.ResultSet other) {
      if (other == com.google.spanner.v1.ResultSet.getDefaultInstance()) return this;
      if (other.hasMetadata()) {
        mergeMetadata(other.getMetadata());
      }
      if (rowsBuilder_ == null) {
        if (!other.rows_.isEmpty()) {
          if (rows_.isEmpty()) {
            rows_ = other.rows_;
            bitField0_ = (bitField0_ & ~0x00000002);
          } else {
            ensureRowsIsMutable();
            rows_.addAll(other.rows_);
          }
          onChanged();
        }
      } else {
        if (!other.rows_.isEmpty()) {
          if (rowsBuilder_.isEmpty()) {
            rowsBuilder_.dispose();
            rowsBuilder_ = null;
            rows_ = other.rows_;
            bitField0_ = (bitField0_ & ~0x00000002);
            rowsBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getRowsFieldBuilder()
                    : null;
          } else {
            rowsBuilder_.addAllMessages(other.rows_);
          }
        }
      }
      if (other.hasStats()) {
        mergeStats(other.getStats());
      }
      this.mergeUnknownFields(other.unknownFields);
      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 {
      com.google.spanner.v1.ResultSet parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.spanner.v1.ResultSet) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private int bitField0_;

    private com.google.spanner.v1.ResultSetMetadata metadata_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.spanner.v1.ResultSetMetadata,
            com.google.spanner.v1.ResultSetMetadata.Builder,
            com.google.spanner.v1.ResultSetMetadataOrBuilder>
        metadataBuilder_;
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public boolean hasMetadata() {
      return metadataBuilder_ != null || metadata_ != null;
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public com.google.spanner.v1.ResultSetMetadata getMetadata() {
      if (metadataBuilder_ == null) {
        return metadata_ == null
            ? com.google.spanner.v1.ResultSetMetadata.getDefaultInstance()
            : metadata_;
      } else {
        return metadataBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public Builder setMetadata(com.google.spanner.v1.ResultSetMetadata value) {
      if (metadataBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        metadata_ = value;
        onChanged();
      } else {
        metadataBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public Builder setMetadata(com.google.spanner.v1.ResultSetMetadata.Builder builderForValue) {
      if (metadataBuilder_ == null) {
        metadata_ = builderForValue.build();
        onChanged();
      } else {
        metadataBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public Builder mergeMetadata(com.google.spanner.v1.ResultSetMetadata value) {
      if (metadataBuilder_ == null) {
        if (metadata_ != null) {
          metadata_ =
              com.google.spanner.v1.ResultSetMetadata.newBuilder(metadata_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          metadata_ = value;
        }
        onChanged();
      } else {
        metadataBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public Builder clearMetadata() {
      if (metadataBuilder_ == null) {
        metadata_ = null;
        onChanged();
      } else {
        metadata_ = null;
        metadataBuilder_ = null;
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public com.google.spanner.v1.ResultSetMetadata.Builder getMetadataBuilder() {

      onChanged();
      return getMetadataFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    public com.google.spanner.v1.ResultSetMetadataOrBuilder getMetadataOrBuilder() {
      if (metadataBuilder_ != null) {
        return metadataBuilder_.getMessageOrBuilder();
      } else {
        return metadata_ == null
            ? com.google.spanner.v1.ResultSetMetadata.getDefaultInstance()
            : metadata_;
      }
    }
    /**
     *
     *
     * <pre>
     * Metadata about the result set, such as row type information.
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetMetadata metadata = 1;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.spanner.v1.ResultSetMetadata,
            com.google.spanner.v1.ResultSetMetadata.Builder,
            com.google.spanner.v1.ResultSetMetadataOrBuilder>
        getMetadataFieldBuilder() {
      if (metadataBuilder_ == null) {
        metadataBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.spanner.v1.ResultSetMetadata,
                com.google.spanner.v1.ResultSetMetadata.Builder,
                com.google.spanner.v1.ResultSetMetadataOrBuilder>(
                getMetadata(), getParentForChildren(), isClean());
        metadata_ = null;
      }
      return metadataBuilder_;
    }

    private java.util.List<com.google.protobuf.ListValue> rows_ = java.util.Collections.emptyList();

    private void ensureRowsIsMutable() {
      if (!((bitField0_ & 0x00000002) != 0)) {
        rows_ = new java.util.ArrayList<com.google.protobuf.ListValue>(rows_);
        bitField0_ |= 0x00000002;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.protobuf.ListValue,
            com.google.protobuf.ListValue.Builder,
            com.google.protobuf.ListValueOrBuilder>
        rowsBuilder_;

    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public java.util.List<com.google.protobuf.ListValue> getRowsList() {
      if (rowsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(rows_);
      } else {
        return rowsBuilder_.getMessageList();
      }
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public int getRowsCount() {
      if (rowsBuilder_ == null) {
        return rows_.size();
      } else {
        return rowsBuilder_.getCount();
      }
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public com.google.protobuf.ListValue getRows(int index) {
      if (rowsBuilder_ == null) {
        return rows_.get(index);
      } else {
        return rowsBuilder_.getMessage(index);
      }
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder setRows(int index, com.google.protobuf.ListValue value) {
      if (rowsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRowsIsMutable();
        rows_.set(index, value);
        onChanged();
      } else {
        rowsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder setRows(int index, com.google.protobuf.ListValue.Builder builderForValue) {
      if (rowsBuilder_ == null) {
        ensureRowsIsMutable();
        rows_.set(index, builderForValue.build());
        onChanged();
      } else {
        rowsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder addRows(com.google.protobuf.ListValue value) {
      if (rowsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRowsIsMutable();
        rows_.add(value);
        onChanged();
      } else {
        rowsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder addRows(int index, com.google.protobuf.ListValue value) {
      if (rowsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureRowsIsMutable();
        rows_.add(index, value);
        onChanged();
      } else {
        rowsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder addRows(com.google.protobuf.ListValue.Builder builderForValue) {
      if (rowsBuilder_ == null) {
        ensureRowsIsMutable();
        rows_.add(builderForValue.build());
        onChanged();
      } else {
        rowsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder addRows(int index, com.google.protobuf.ListValue.Builder builderForValue) {
      if (rowsBuilder_ == null) {
        ensureRowsIsMutable();
        rows_.add(index, builderForValue.build());
        onChanged();
      } else {
        rowsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder addAllRows(java.lang.Iterable<? extends com.google.protobuf.ListValue> values) {
      if (rowsBuilder_ == null) {
        ensureRowsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, rows_);
        onChanged();
      } else {
        rowsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder clearRows() {
      if (rowsBuilder_ == null) {
        rows_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000002);
        onChanged();
      } else {
        rowsBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public Builder removeRows(int index) {
      if (rowsBuilder_ == null) {
        ensureRowsIsMutable();
        rows_.remove(index);
        onChanged();
      } else {
        rowsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public com.google.protobuf.ListValue.Builder getRowsBuilder(int index) {
      return getRowsFieldBuilder().getBuilder(index);
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public com.google.protobuf.ListValueOrBuilder getRowsOrBuilder(int index) {
      if (rowsBuilder_ == null) {
        return rows_.get(index);
      } else {
        return rowsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public java.util.List<? extends com.google.protobuf.ListValueOrBuilder> getRowsOrBuilderList() {
      if (rowsBuilder_ != null) {
        return rowsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(rows_);
      }
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public com.google.protobuf.ListValue.Builder addRowsBuilder() {
      return getRowsFieldBuilder().addBuilder(com.google.protobuf.ListValue.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public com.google.protobuf.ListValue.Builder addRowsBuilder(int index) {
      return getRowsFieldBuilder()
          .addBuilder(index, com.google.protobuf.ListValue.getDefaultInstance());
    }
    /**
     *
     *
     * <pre>
     * Each element in `rows` is a row whose format is defined by
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
     * element in each row matches the ith field in
     * [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
     * are encoded based on type as described [here][google.spanner.v1.TypeCode].
     * </pre>
     *
     * <code>repeated .google.protobuf.ListValue rows = 2;</code>
     */
    public java.util.List<com.google.protobuf.ListValue.Builder> getRowsBuilderList() {
      return getRowsFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.protobuf.ListValue,
            com.google.protobuf.ListValue.Builder,
            com.google.protobuf.ListValueOrBuilder>
        getRowsFieldBuilder() {
      if (rowsBuilder_ == null) {
        rowsBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                com.google.protobuf.ListValue,
                com.google.protobuf.ListValue.Builder,
                com.google.protobuf.ListValueOrBuilder>(
                rows_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean());
        rows_ = null;
      }
      return rowsBuilder_;
    }

    private com.google.spanner.v1.ResultSetStats stats_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.spanner.v1.ResultSetStats,
            com.google.spanner.v1.ResultSetStats.Builder,
            com.google.spanner.v1.ResultSetStatsOrBuilder>
        statsBuilder_;
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public boolean hasStats() {
      return statsBuilder_ != null || stats_ != null;
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public com.google.spanner.v1.ResultSetStats getStats() {
      if (statsBuilder_ == null) {
        return stats_ == null ? com.google.spanner.v1.ResultSetStats.getDefaultInstance() : stats_;
      } else {
        return statsBuilder_.getMessage();
      }
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public Builder setStats(com.google.spanner.v1.ResultSetStats value) {
      if (statsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        stats_ = value;
        onChanged();
      } else {
        statsBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public Builder setStats(com.google.spanner.v1.ResultSetStats.Builder builderForValue) {
      if (statsBuilder_ == null) {
        stats_ = builderForValue.build();
        onChanged();
      } else {
        statsBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public Builder mergeStats(com.google.spanner.v1.ResultSetStats value) {
      if (statsBuilder_ == null) {
        if (stats_ != null) {
          stats_ =
              com.google.spanner.v1.ResultSetStats.newBuilder(stats_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          stats_ = value;
        }
        onChanged();
      } else {
        statsBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public Builder clearStats() {
      if (statsBuilder_ == null) {
        stats_ = null;
        onChanged();
      } else {
        stats_ = null;
        statsBuilder_ = null;
      }

      return this;
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public com.google.spanner.v1.ResultSetStats.Builder getStatsBuilder() {

      onChanged();
      return getStatsFieldBuilder().getBuilder();
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    public com.google.spanner.v1.ResultSetStatsOrBuilder getStatsOrBuilder() {
      if (statsBuilder_ != null) {
        return statsBuilder_.getMessageOrBuilder();
      } else {
        return stats_ == null ? com.google.spanner.v1.ResultSetStats.getDefaultInstance() : stats_;
      }
    }
    /**
     *
     *
     * <pre>
     * Query plan and execution statistics for the SQL statement that
     * produced this result set. These can be requested by setting
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * DML statements always produce stats containing the number of rows
     * modified, unless executed using the
     * [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * Other fields may or may not be populated, based on the
     * [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
     * </pre>
     *
     * <code>.google.spanner.v1.ResultSetStats stats = 3;</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.spanner.v1.ResultSetStats,
            com.google.spanner.v1.ResultSetStats.Builder,
            com.google.spanner.v1.ResultSetStatsOrBuilder>
        getStatsFieldBuilder() {
      if (statsBuilder_ == null) {
        statsBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.spanner.v1.ResultSetStats,
                com.google.spanner.v1.ResultSetStats.Builder,
                com.google.spanner.v1.ResultSetStatsOrBuilder>(
                getStats(), getParentForChildren(), isClean());
        stats_ = null;
      }
      return statsBuilder_;
    }

    @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.spanner.v1.ResultSet)
  }

  // @@protoc_insertion_point(class_scope:google.spanner.v1.ResultSet)
  private static final com.google.spanner.v1.ResultSet DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.spanner.v1.ResultSet();
  }

  public static com.google.spanner.v1.ResultSet getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  @java.lang.Override
  public com.google.spanner.v1.ResultSet getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
