/*
 * Copyright 2026 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!
// NO CHECKED-IN PROTOBUF GENCODE
// source: google/firestore/v1/firestore.proto
// Protobuf Java Version: 4.33.2

package com.google.firestore.v1;

/**
 *
 *
 * <pre>
 * The response for
 * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
 * </pre>
 *
 * Protobuf type {@code google.firestore.v1.RunAggregationQueryResponse}
 */
@com.google.protobuf.Generated
public final class RunAggregationQueryResponse extends com.google.protobuf.GeneratedMessage
    implements
    // @@protoc_insertion_point(message_implements:google.firestore.v1.RunAggregationQueryResponse)
    RunAggregationQueryResponseOrBuilder {
  private static final long serialVersionUID = 0L;

  static {
    com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
        com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
        /* major= */ 4,
        /* minor= */ 33,
        /* patch= */ 2,
        /* suffix= */ "",
        "RunAggregationQueryResponse");
  }

  // Use RunAggregationQueryResponse.newBuilder() to construct.
  private RunAggregationQueryResponse(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
    super(builder);
  }

  private RunAggregationQueryResponse() {
    transaction_ = com.google.protobuf.ByteString.EMPTY;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.firestore.v1.FirestoreProto
        .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.firestore.v1.FirestoreProto
        .internal_static_google_firestore_v1_RunAggregationQueryResponse_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.firestore.v1.RunAggregationQueryResponse.class,
            com.google.firestore.v1.RunAggregationQueryResponse.Builder.class);
  }

  private int bitField0_;
  public static final int RESULT_FIELD_NUMBER = 1;
  private com.google.firestore.v1.AggregationResult result_;

  /**
   *
   *
   * <pre>
   * A single aggregation result.
   *
   * Not present when reporting partial progress.
   * </pre>
   *
   * <code>.google.firestore.v1.AggregationResult result = 1;</code>
   *
   * @return Whether the result field is set.
   */
  @java.lang.Override
  public boolean hasResult() {
    return ((bitField0_ & 0x00000001) != 0);
  }

  /**
   *
   *
   * <pre>
   * A single aggregation result.
   *
   * Not present when reporting partial progress.
   * </pre>
   *
   * <code>.google.firestore.v1.AggregationResult result = 1;</code>
   *
   * @return The result.
   */
  @java.lang.Override
  public com.google.firestore.v1.AggregationResult getResult() {
    return result_ == null
        ? com.google.firestore.v1.AggregationResult.getDefaultInstance()
        : result_;
  }

  /**
   *
   *
   * <pre>
   * A single aggregation result.
   *
   * Not present when reporting partial progress.
   * </pre>
   *
   * <code>.google.firestore.v1.AggregationResult result = 1;</code>
   */
  @java.lang.Override
  public com.google.firestore.v1.AggregationResultOrBuilder getResultOrBuilder() {
    return result_ == null
        ? com.google.firestore.v1.AggregationResult.getDefaultInstance()
        : result_;
  }

  public static final int TRANSACTION_FIELD_NUMBER = 2;
  private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY;

  /**
   *
   *
   * <pre>
   * The transaction that was started as part of this request.
   *
   * Only present on the first response when the request requested to start
   * a new transaction.
   * </pre>
   *
   * <code>bytes transaction = 2;</code>
   *
   * @return The transaction.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getTransaction() {
    return transaction_;
  }

  public static final int READ_TIME_FIELD_NUMBER = 3;
  private com.google.protobuf.Timestamp readTime_;

  /**
   *
   *
   * <pre>
   * The time at which the aggregate result was computed. This is always
   * monotonically increasing; in this case, the previous AggregationResult in
   * the result stream are guaranteed not to have changed between their
   * `read_time` and this one.
   *
   * If the query returns no results, a response with `read_time` and no
   * `result` will be sent, and this represents the time at which the query
   * was run.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp read_time = 3;</code>
   *
   * @return Whether the readTime field is set.
   */
  @java.lang.Override
  public boolean hasReadTime() {
    return ((bitField0_ & 0x00000002) != 0);
  }

  /**
   *
   *
   * <pre>
   * The time at which the aggregate result was computed. This is always
   * monotonically increasing; in this case, the previous AggregationResult in
   * the result stream are guaranteed not to have changed between their
   * `read_time` and this one.
   *
   * If the query returns no results, a response with `read_time` and no
   * `result` will be sent, and this represents the time at which the query
   * was run.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp read_time = 3;</code>
   *
   * @return The readTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getReadTime() {
    return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_;
  }

  /**
   *
   *
   * <pre>
   * The time at which the aggregate result was computed. This is always
   * monotonically increasing; in this case, the previous AggregationResult in
   * the result stream are guaranteed not to have changed between their
   * `read_time` and this one.
   *
   * If the query returns no results, a response with `read_time` and no
   * `result` will be sent, and this represents the time at which the query
   * was run.
   * </pre>
   *
   * <code>.google.protobuf.Timestamp read_time = 3;</code>
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() {
    return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_;
  }

  public static final int EXPLAIN_METRICS_FIELD_NUMBER = 10;
  private com.google.firestore.v1.ExplainMetrics explainMetrics_;

  /**
   *
   *
   * <pre>
   * Query explain metrics. This is only present when the
   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
   * is provided, and it is sent only once with the last response in the stream.
   * </pre>
   *
   * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
   *
   * @return Whether the explainMetrics field is set.
   */
  @java.lang.Override
  public boolean hasExplainMetrics() {
    return ((bitField0_ & 0x00000004) != 0);
  }

  /**
   *
   *
   * <pre>
   * Query explain metrics. This is only present when the
   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
   * is provided, and it is sent only once with the last response in the stream.
   * </pre>
   *
   * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
   *
   * @return The explainMetrics.
   */
  @java.lang.Override
  public com.google.firestore.v1.ExplainMetrics getExplainMetrics() {
    return explainMetrics_ == null
        ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance()
        : explainMetrics_;
  }

  /**
   *
   *
   * <pre>
   * Query explain metrics. This is only present when the
   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
   * is provided, and it is sent only once with the last response in the stream.
   * </pre>
   *
   * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
   */
  @java.lang.Override
  public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() {
    return explainMetrics_ == null
        ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance()
        : explainMetrics_;
  }

  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 (((bitField0_ & 0x00000001) != 0)) {
      output.writeMessage(1, getResult());
    }
    if (!transaction_.isEmpty()) {
      output.writeBytes(2, transaction_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      output.writeMessage(3, getReadTime());
    }
    if (((bitField0_ & 0x00000004) != 0)) {
      output.writeMessage(10, getExplainMetrics());
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    if (((bitField0_ & 0x00000001) != 0)) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getResult());
    }
    if (!transaction_.isEmpty()) {
      size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, transaction_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getReadTime());
    }
    if (((bitField0_ & 0x00000004) != 0)) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getExplainMetrics());
    }
    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.firestore.v1.RunAggregationQueryResponse)) {
      return super.equals(obj);
    }
    com.google.firestore.v1.RunAggregationQueryResponse other =
        (com.google.firestore.v1.RunAggregationQueryResponse) obj;

    if (hasResult() != other.hasResult()) return false;
    if (hasResult()) {
      if (!getResult().equals(other.getResult())) return false;
    }
    if (!getTransaction().equals(other.getTransaction())) return false;
    if (hasReadTime() != other.hasReadTime()) return false;
    if (hasReadTime()) {
      if (!getReadTime().equals(other.getReadTime())) return false;
    }
    if (hasExplainMetrics() != other.hasExplainMetrics()) return false;
    if (hasExplainMetrics()) {
      if (!getExplainMetrics().equals(other.getExplainMetrics())) 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 (hasResult()) {
      hash = (37 * hash) + RESULT_FIELD_NUMBER;
      hash = (53 * hash) + getResult().hashCode();
    }
    hash = (37 * hash) + TRANSACTION_FIELD_NUMBER;
    hash = (53 * hash) + getTransaction().hashCode();
    if (hasReadTime()) {
      hash = (37 * hash) + READ_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getReadTime().hashCode();
    }
    if (hasExplainMetrics()) {
      hash = (37 * hash) + EXPLAIN_METRICS_FIELD_NUMBER;
      hash = (53 * hash) + getExplainMetrics().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

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

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

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

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

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

  public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessage.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.firestore.v1.RunAggregationQueryResponse 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.GeneratedMessage.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }

  /**
   *
   *
   * <pre>
   * The response for
   * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
   * </pre>
   *
   * Protobuf type {@code google.firestore.v1.RunAggregationQueryResponse}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.firestore.v1.RunAggregationQueryResponse)
      com.google.firestore.v1.RunAggregationQueryResponseOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.firestore.v1.FirestoreProto
          .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.firestore.v1.FirestoreProto
          .internal_static_google_firestore_v1_RunAggregationQueryResponse_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.firestore.v1.RunAggregationQueryResponse.class,
              com.google.firestore.v1.RunAggregationQueryResponse.Builder.class);
    }

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

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

    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
        internalGetResultFieldBuilder();
        internalGetReadTimeFieldBuilder();
        internalGetExplainMetricsFieldBuilder();
      }
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      result_ = null;
      if (resultBuilder_ != null) {
        resultBuilder_.dispose();
        resultBuilder_ = null;
      }
      transaction_ = com.google.protobuf.ByteString.EMPTY;
      readTime_ = null;
      if (readTimeBuilder_ != null) {
        readTimeBuilder_.dispose();
        readTimeBuilder_ = null;
      }
      explainMetrics_ = null;
      if (explainMetricsBuilder_ != null) {
        explainMetricsBuilder_.dispose();
        explainMetricsBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.firestore.v1.FirestoreProto
          .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor;
    }

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

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

    @java.lang.Override
    public com.google.firestore.v1.RunAggregationQueryResponse buildPartial() {
      com.google.firestore.v1.RunAggregationQueryResponse result =
          new com.google.firestore.v1.RunAggregationQueryResponse(this);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartial0(com.google.firestore.v1.RunAggregationQueryResponse result) {
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.result_ = resultBuilder_ == null ? result_ : resultBuilder_.build();
        to_bitField0_ |= 0x00000001;
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.transaction_ = transaction_;
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build();
        to_bitField0_ |= 0x00000002;
      }
      if (((from_bitField0_ & 0x00000008) != 0)) {
        result.explainMetrics_ =
            explainMetricsBuilder_ == null ? explainMetrics_ : explainMetricsBuilder_.build();
        to_bitField0_ |= 0x00000004;
      }
      result.bitField0_ |= to_bitField0_;
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.firestore.v1.RunAggregationQueryResponse) {
        return mergeFrom((com.google.firestore.v1.RunAggregationQueryResponse) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.firestore.v1.RunAggregationQueryResponse other) {
      if (other == com.google.firestore.v1.RunAggregationQueryResponse.getDefaultInstance())
        return this;
      if (other.hasResult()) {
        mergeResult(other.getResult());
      }
      if (!other.getTransaction().isEmpty()) {
        setTransaction(other.getTransaction());
      }
      if (other.hasReadTime()) {
        mergeReadTime(other.getReadTime());
      }
      if (other.hasExplainMetrics()) {
        mergeExplainMetrics(other.getExplainMetrics());
      }
      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:
              {
                input.readMessage(internalGetResultFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 18:
              {
                transaction_ = input.readBytes();
                bitField0_ |= 0x00000002;
                break;
              } // case 18
            case 26:
              {
                input.readMessage(
                    internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000004;
                break;
              } // case 26
            case 82:
              {
                input.readMessage(
                    internalGetExplainMetricsFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000008;
                break;
              } // case 82
            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 com.google.firestore.v1.AggregationResult result_;
    private com.google.protobuf.SingleFieldBuilder<
            com.google.firestore.v1.AggregationResult,
            com.google.firestore.v1.AggregationResult.Builder,
            com.google.firestore.v1.AggregationResultOrBuilder>
        resultBuilder_;

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     *
     * @return Whether the result field is set.
     */
    public boolean hasResult() {
      return ((bitField0_ & 0x00000001) != 0);
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     *
     * @return The result.
     */
    public com.google.firestore.v1.AggregationResult getResult() {
      if (resultBuilder_ == null) {
        return result_ == null
            ? com.google.firestore.v1.AggregationResult.getDefaultInstance()
            : result_;
      } else {
        return resultBuilder_.getMessage();
      }
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public Builder setResult(com.google.firestore.v1.AggregationResult value) {
      if (resultBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        result_ = value;
      } else {
        resultBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public Builder setResult(com.google.firestore.v1.AggregationResult.Builder builderForValue) {
      if (resultBuilder_ == null) {
        result_ = builderForValue.build();
      } else {
        resultBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public Builder mergeResult(com.google.firestore.v1.AggregationResult value) {
      if (resultBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)
            && result_ != null
            && result_ != com.google.firestore.v1.AggregationResult.getDefaultInstance()) {
          getResultBuilder().mergeFrom(value);
        } else {
          result_ = value;
        }
      } else {
        resultBuilder_.mergeFrom(value);
      }
      if (result_ != null) {
        bitField0_ |= 0x00000001;
        onChanged();
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public Builder clearResult() {
      bitField0_ = (bitField0_ & ~0x00000001);
      result_ = null;
      if (resultBuilder_ != null) {
        resultBuilder_.dispose();
        resultBuilder_ = null;
      }
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public com.google.firestore.v1.AggregationResult.Builder getResultBuilder() {
      bitField0_ |= 0x00000001;
      onChanged();
      return internalGetResultFieldBuilder().getBuilder();
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    public com.google.firestore.v1.AggregationResultOrBuilder getResultOrBuilder() {
      if (resultBuilder_ != null) {
        return resultBuilder_.getMessageOrBuilder();
      } else {
        return result_ == null
            ? com.google.firestore.v1.AggregationResult.getDefaultInstance()
            : result_;
      }
    }

    /**
     *
     *
     * <pre>
     * A single aggregation result.
     *
     * Not present when reporting partial progress.
     * </pre>
     *
     * <code>.google.firestore.v1.AggregationResult result = 1;</code>
     */
    private com.google.protobuf.SingleFieldBuilder<
            com.google.firestore.v1.AggregationResult,
            com.google.firestore.v1.AggregationResult.Builder,
            com.google.firestore.v1.AggregationResultOrBuilder>
        internalGetResultFieldBuilder() {
      if (resultBuilder_ == null) {
        resultBuilder_ =
            new com.google.protobuf.SingleFieldBuilder<
                com.google.firestore.v1.AggregationResult,
                com.google.firestore.v1.AggregationResult.Builder,
                com.google.firestore.v1.AggregationResultOrBuilder>(
                getResult(), getParentForChildren(), isClean());
        result_ = null;
      }
      return resultBuilder_;
    }

    private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY;

    /**
     *
     *
     * <pre>
     * The transaction that was started as part of this request.
     *
     * Only present on the first response when the request requested to start
     * a new transaction.
     * </pre>
     *
     * <code>bytes transaction = 2;</code>
     *
     * @return The transaction.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString getTransaction() {
      return transaction_;
    }

    /**
     *
     *
     * <pre>
     * The transaction that was started as part of this request.
     *
     * Only present on the first response when the request requested to start
     * a new transaction.
     * </pre>
     *
     * <code>bytes transaction = 2;</code>
     *
     * @param value The transaction to set.
     * @return This builder for chaining.
     */
    public Builder setTransaction(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      transaction_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * The transaction that was started as part of this request.
     *
     * Only present on the first response when the request requested to start
     * a new transaction.
     * </pre>
     *
     * <code>bytes transaction = 2;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearTransaction() {
      bitField0_ = (bitField0_ & ~0x00000002);
      transaction_ = getDefaultInstance().getTransaction();
      onChanged();
      return this;
    }

    private com.google.protobuf.Timestamp readTime_;
    private com.google.protobuf.SingleFieldBuilder<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        readTimeBuilder_;

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     *
     * @return Whether the readTime field is set.
     */
    public boolean hasReadTime() {
      return ((bitField0_ & 0x00000004) != 0);
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     *
     * @return The readTime.
     */
    public com.google.protobuf.Timestamp getReadTime() {
      if (readTimeBuilder_ == null) {
        return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_;
      } else {
        return readTimeBuilder_.getMessage();
      }
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public Builder setReadTime(com.google.protobuf.Timestamp value) {
      if (readTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        readTime_ = value;
      } else {
        readTimeBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000004;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (readTimeBuilder_ == null) {
        readTime_ = builderForValue.build();
      } else {
        readTimeBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000004;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public Builder mergeReadTime(com.google.protobuf.Timestamp value) {
      if (readTimeBuilder_ == null) {
        if (((bitField0_ & 0x00000004) != 0)
            && readTime_ != null
            && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          getReadTimeBuilder().mergeFrom(value);
        } else {
          readTime_ = value;
        }
      } else {
        readTimeBuilder_.mergeFrom(value);
      }
      if (readTime_ != null) {
        bitField0_ |= 0x00000004;
        onChanged();
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public Builder clearReadTime() {
      bitField0_ = (bitField0_ & ~0x00000004);
      readTime_ = null;
      if (readTimeBuilder_ != null) {
        readTimeBuilder_.dispose();
        readTimeBuilder_ = null;
      }
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() {
      bitField0_ |= 0x00000004;
      onChanged();
      return internalGetReadTimeFieldBuilder().getBuilder();
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() {
      if (readTimeBuilder_ != null) {
        return readTimeBuilder_.getMessageOrBuilder();
      } else {
        return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_;
      }
    }

    /**
     *
     *
     * <pre>
     * The time at which the aggregate result was computed. This is always
     * monotonically increasing; in this case, the previous AggregationResult in
     * the result stream are guaranteed not to have changed between their
     * `read_time` and this one.
     *
     * If the query returns no results, a response with `read_time` and no
     * `result` will be sent, and this represents the time at which the query
     * was run.
     * </pre>
     *
     * <code>.google.protobuf.Timestamp read_time = 3;</code>
     */
    private com.google.protobuf.SingleFieldBuilder<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        internalGetReadTimeFieldBuilder() {
      if (readTimeBuilder_ == null) {
        readTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilder<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getReadTime(), getParentForChildren(), isClean());
        readTime_ = null;
      }
      return readTimeBuilder_;
    }

    private com.google.firestore.v1.ExplainMetrics explainMetrics_;
    private com.google.protobuf.SingleFieldBuilder<
            com.google.firestore.v1.ExplainMetrics,
            com.google.firestore.v1.ExplainMetrics.Builder,
            com.google.firestore.v1.ExplainMetricsOrBuilder>
        explainMetricsBuilder_;

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     *
     * @return Whether the explainMetrics field is set.
     */
    public boolean hasExplainMetrics() {
      return ((bitField0_ & 0x00000008) != 0);
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     *
     * @return The explainMetrics.
     */
    public com.google.firestore.v1.ExplainMetrics getExplainMetrics() {
      if (explainMetricsBuilder_ == null) {
        return explainMetrics_ == null
            ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance()
            : explainMetrics_;
      } else {
        return explainMetricsBuilder_.getMessage();
      }
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public Builder setExplainMetrics(com.google.firestore.v1.ExplainMetrics value) {
      if (explainMetricsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        explainMetrics_ = value;
      } else {
        explainMetricsBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000008;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public Builder setExplainMetrics(
        com.google.firestore.v1.ExplainMetrics.Builder builderForValue) {
      if (explainMetricsBuilder_ == null) {
        explainMetrics_ = builderForValue.build();
      } else {
        explainMetricsBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000008;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public Builder mergeExplainMetrics(com.google.firestore.v1.ExplainMetrics value) {
      if (explainMetricsBuilder_ == null) {
        if (((bitField0_ & 0x00000008) != 0)
            && explainMetrics_ != null
            && explainMetrics_ != com.google.firestore.v1.ExplainMetrics.getDefaultInstance()) {
          getExplainMetricsBuilder().mergeFrom(value);
        } else {
          explainMetrics_ = value;
        }
      } else {
        explainMetricsBuilder_.mergeFrom(value);
      }
      if (explainMetrics_ != null) {
        bitField0_ |= 0x00000008;
        onChanged();
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public Builder clearExplainMetrics() {
      bitField0_ = (bitField0_ & ~0x00000008);
      explainMetrics_ = null;
      if (explainMetricsBuilder_ != null) {
        explainMetricsBuilder_.dispose();
        explainMetricsBuilder_ = null;
      }
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public com.google.firestore.v1.ExplainMetrics.Builder getExplainMetricsBuilder() {
      bitField0_ |= 0x00000008;
      onChanged();
      return internalGetExplainMetricsFieldBuilder().getBuilder();
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() {
      if (explainMetricsBuilder_ != null) {
        return explainMetricsBuilder_.getMessageOrBuilder();
      } else {
        return explainMetrics_ == null
            ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance()
            : explainMetrics_;
      }
    }

    /**
     *
     *
     * <pre>
     * Query explain metrics. This is only present when the
     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
     * is provided, and it is sent only once with the last response in the stream.
     * </pre>
     *
     * <code>.google.firestore.v1.ExplainMetrics explain_metrics = 10;</code>
     */
    private com.google.protobuf.SingleFieldBuilder<
            com.google.firestore.v1.ExplainMetrics,
            com.google.firestore.v1.ExplainMetrics.Builder,
            com.google.firestore.v1.ExplainMetricsOrBuilder>
        internalGetExplainMetricsFieldBuilder() {
      if (explainMetricsBuilder_ == null) {
        explainMetricsBuilder_ =
            new com.google.protobuf.SingleFieldBuilder<
                com.google.firestore.v1.ExplainMetrics,
                com.google.firestore.v1.ExplainMetrics.Builder,
                com.google.firestore.v1.ExplainMetricsOrBuilder>(
                getExplainMetrics(), getParentForChildren(), isClean());
        explainMetrics_ = null;
      }
      return explainMetricsBuilder_;
    }

    // @@protoc_insertion_point(builder_scope:google.firestore.v1.RunAggregationQueryResponse)
  }

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

  static {
    DEFAULT_INSTANCE = new com.google.firestore.v1.RunAggregationQueryResponse();
  }

  public static com.google.firestore.v1.RunAggregationQueryResponse getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<RunAggregationQueryResponse> PARSER =
      new com.google.protobuf.AbstractParser<RunAggregationQueryResponse>() {
        @java.lang.Override
        public RunAggregationQueryResponse 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<RunAggregationQueryResponse> parser() {
    return PARSER;
  }

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

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