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

// Protobuf Java Version: 3.25.8
package com.google.pubsub.v1;

/**
 *
 *
 * <pre>
 * A message and its corresponding acknowledgment ID.
 * </pre>
 *
 * Protobuf type {@code google.pubsub.v1.ReceivedMessage}
 */
public final class ReceivedMessage extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.pubsub.v1.ReceivedMessage)
    ReceivedMessageOrBuilder {
  private static final long serialVersionUID = 0L;

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

  private ReceivedMessage() {
    ackId_ = "";
  }

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

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.pubsub.v1.PubsubProto
        .internal_static_google_pubsub_v1_ReceivedMessage_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.pubsub.v1.PubsubProto
        .internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.pubsub.v1.ReceivedMessage.class,
            com.google.pubsub.v1.ReceivedMessage.Builder.class);
  }

  private int bitField0_;
  public static final int ACK_ID_FIELD_NUMBER = 1;

  @SuppressWarnings("serial")
  private volatile java.lang.Object ackId_ = "";

  /**
   *
   *
   * <pre>
   * Optional. This ID can be used to acknowledge the received message.
   * </pre>
   *
   * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
   *
   * @return The ackId.
   */
  @java.lang.Override
  public java.lang.String getAckId() {
    java.lang.Object ref = ackId_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      ackId_ = s;
      return s;
    }
  }

  /**
   *
   *
   * <pre>
   * Optional. This ID can be used to acknowledge the received message.
   * </pre>
   *
   * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
   *
   * @return The bytes for ackId.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getAckIdBytes() {
    java.lang.Object ref = ackId_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      ackId_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int MESSAGE_FIELD_NUMBER = 2;
  private com.google.pubsub.v1.PubsubMessage message_;

  /**
   *
   *
   * <pre>
   * Optional. The message.
   * </pre>
   *
   * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   *
   * @return Whether the message field is set.
   */
  @java.lang.Override
  public boolean hasMessage() {
    return ((bitField0_ & 0x00000001) != 0);
  }

  /**
   *
   *
   * <pre>
   * Optional. The message.
   * </pre>
   *
   * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   *
   * @return The message.
   */
  @java.lang.Override
  public com.google.pubsub.v1.PubsubMessage getMessage() {
    return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_;
  }

  /**
   *
   *
   * <pre>
   * Optional. The message.
   * </pre>
   *
   * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
   * </code>
   */
  @java.lang.Override
  public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() {
    return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_;
  }

  public static final int DELIVERY_ATTEMPT_FIELD_NUMBER = 3;
  private int deliveryAttempt_ = 0;

  /**
   *
   *
   * <pre>
   * Optional. The approximate number of times that Pub/Sub has attempted to
   * deliver the associated message to a subscriber.
   *
   * More precisely, this is 1 + (number of NACKs) +
   * (number of ack_deadline exceeds) for this message.
   *
   * A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
   * exceeds event is whenever a message is not acknowledged within
   * ack_deadline. Note that ack_deadline is initially
   * Subscription.ackDeadlineSeconds, but may get extended automatically by
   * the client library.
   *
   * Upon the first delivery of a given message, `delivery_attempt` will have a
   * value of 1. The value is calculated at best effort and is approximate.
   *
   * If a DeadLetterPolicy is not set on the subscription, this will be 0.
   * </pre>
   *
   * <code>int32 delivery_attempt = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
   *
   * @return The deliveryAttempt.
   */
  @java.lang.Override
  public int getDeliveryAttempt() {
    return deliveryAttempt_;
  }

  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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(ackId_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, ackId_);
    }
    if (((bitField0_ & 0x00000001) != 0)) {
      output.writeMessage(2, getMessage());
    }
    if (deliveryAttempt_ != 0) {
      output.writeInt32(3, deliveryAttempt_);
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(ackId_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, ackId_);
    }
    if (((bitField0_ & 0x00000001) != 0)) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getMessage());
    }
    if (deliveryAttempt_ != 0) {
      size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, deliveryAttempt_);
    }
    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.pubsub.v1.ReceivedMessage)) {
      return super.equals(obj);
    }
    com.google.pubsub.v1.ReceivedMessage other = (com.google.pubsub.v1.ReceivedMessage) obj;

    if (!getAckId().equals(other.getAckId())) return false;
    if (hasMessage() != other.hasMessage()) return false;
    if (hasMessage()) {
      if (!getMessage().equals(other.getMessage())) return false;
    }
    if (getDeliveryAttempt() != other.getDeliveryAttempt()) 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();
    hash = (37 * hash) + ACK_ID_FIELD_NUMBER;
    hash = (53 * hash) + getAckId().hashCode();
    if (hasMessage()) {
      hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
      hash = (53 * hash) + getMessage().hashCode();
    }
    hash = (37 * hash) + DELIVERY_ATTEMPT_FIELD_NUMBER;
    hash = (53 * hash) + getDeliveryAttempt();
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

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

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

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

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

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

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

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

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

  public static com.google.pubsub.v1.ReceivedMessage 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.pubsub.v1.ReceivedMessage 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>
   * A message and its corresponding acknowledgment ID.
   * </pre>
   *
   * Protobuf type {@code google.pubsub.v1.ReceivedMessage}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ReceivedMessage)
      com.google.pubsub.v1.ReceivedMessageOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.pubsub.v1.PubsubProto
          .internal_static_google_pubsub_v1_ReceivedMessage_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.pubsub.v1.PubsubProto
          .internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.pubsub.v1.ReceivedMessage.class,
              com.google.pubsub.v1.ReceivedMessage.Builder.class);
    }

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

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

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      ackId_ = "";
      message_ = null;
      if (messageBuilder_ != null) {
        messageBuilder_.dispose();
        messageBuilder_ = null;
      }
      deliveryAttempt_ = 0;
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.pubsub.v1.PubsubProto
          .internal_static_google_pubsub_v1_ReceivedMessage_descriptor;
    }

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

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

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

    private void buildPartial0(com.google.pubsub.v1.ReceivedMessage result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.ackId_ = ackId_;
      }
      int to_bitField0_ = 0;
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.message_ = messageBuilder_ == null ? message_ : messageBuilder_.build();
        to_bitField0_ |= 0x00000001;
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.deliveryAttempt_ = deliveryAttempt_;
      }
      result.bitField0_ |= to_bitField0_;
    }

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

    public Builder mergeFrom(com.google.pubsub.v1.ReceivedMessage other) {
      if (other == com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()) return this;
      if (!other.getAckId().isEmpty()) {
        ackId_ = other.ackId_;
        bitField0_ |= 0x00000001;
        onChanged();
      }
      if (other.hasMessage()) {
        mergeMessage(other.getMessage());
      }
      if (other.getDeliveryAttempt() != 0) {
        setDeliveryAttempt(other.getDeliveryAttempt());
      }
      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:
              {
                ackId_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 18:
              {
                input.readMessage(getMessageFieldBuilder().getBuilder(), extensionRegistry);
                bitField0_ |= 0x00000002;
                break;
              } // case 18
            case 24:
              {
                deliveryAttempt_ = input.readInt32();
                bitField0_ |= 0x00000004;
                break;
              } // case 24
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.lang.Object ackId_ = "";

    /**
     *
     *
     * <pre>
     * Optional. This ID can be used to acknowledge the received message.
     * </pre>
     *
     * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return The ackId.
     */
    public java.lang.String getAckId() {
      java.lang.Object ref = ackId_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        ackId_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }

    /**
     *
     *
     * <pre>
     * Optional. This ID can be used to acknowledge the received message.
     * </pre>
     *
     * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return The bytes for ackId.
     */
    public com.google.protobuf.ByteString getAckIdBytes() {
      java.lang.Object ref = ackId_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        ackId_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }

    /**
     *
     *
     * <pre>
     * Optional. This ID can be used to acknowledge the received message.
     * </pre>
     *
     * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @param value The ackId to set.
     * @return This builder for chaining.
     */
    public Builder setAckId(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ackId_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. This ID can be used to acknowledge the received message.
     * </pre>
     *
     * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearAckId() {
      ackId_ = getDefaultInstance().getAckId();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. This ID can be used to acknowledge the received message.
     * </pre>
     *
     * <code>string ack_id = 1 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @param value The bytes for ackId to set.
     * @return This builder for chaining.
     */
    public Builder setAckIdBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      ackId_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }

    private com.google.pubsub.v1.PubsubMessage message_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.pubsub.v1.PubsubMessage,
            com.google.pubsub.v1.PubsubMessage.Builder,
            com.google.pubsub.v1.PubsubMessageOrBuilder>
        messageBuilder_;

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     *
     * @return Whether the message field is set.
     */
    public boolean hasMessage() {
      return ((bitField0_ & 0x00000002) != 0);
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     *
     * @return The message.
     */
    public com.google.pubsub.v1.PubsubMessage getMessage() {
      if (messageBuilder_ == null) {
        return message_ == null
            ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance()
            : message_;
      } else {
        return messageBuilder_.getMessage();
      }
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder setMessage(com.google.pubsub.v1.PubsubMessage value) {
      if (messageBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        message_ = value;
      } else {
        messageBuilder_.setMessage(value);
      }
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder setMessage(com.google.pubsub.v1.PubsubMessage.Builder builderForValue) {
      if (messageBuilder_ == null) {
        message_ = builderForValue.build();
      } else {
        messageBuilder_.setMessage(builderForValue.build());
      }
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder mergeMessage(com.google.pubsub.v1.PubsubMessage value) {
      if (messageBuilder_ == null) {
        if (((bitField0_ & 0x00000002) != 0)
            && message_ != null
            && message_ != com.google.pubsub.v1.PubsubMessage.getDefaultInstance()) {
          getMessageBuilder().mergeFrom(value);
        } else {
          message_ = value;
        }
      } else {
        messageBuilder_.mergeFrom(value);
      }
      if (message_ != null) {
        bitField0_ |= 0x00000002;
        onChanged();
      }
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public Builder clearMessage() {
      bitField0_ = (bitField0_ & ~0x00000002);
      message_ = null;
      if (messageBuilder_ != null) {
        messageBuilder_.dispose();
        messageBuilder_ = null;
      }
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public com.google.pubsub.v1.PubsubMessage.Builder getMessageBuilder() {
      bitField0_ |= 0x00000002;
      onChanged();
      return getMessageFieldBuilder().getBuilder();
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() {
      if (messageBuilder_ != null) {
        return messageBuilder_.getMessageOrBuilder();
      } else {
        return message_ == null
            ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance()
            : message_;
      }
    }

    /**
     *
     *
     * <pre>
     * Optional. The message.
     * </pre>
     *
     * <code>.google.pubsub.v1.PubsubMessage message = 2 [(.google.api.field_behavior) = OPTIONAL];
     * </code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.pubsub.v1.PubsubMessage,
            com.google.pubsub.v1.PubsubMessage.Builder,
            com.google.pubsub.v1.PubsubMessageOrBuilder>
        getMessageFieldBuilder() {
      if (messageBuilder_ == null) {
        messageBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.pubsub.v1.PubsubMessage,
                com.google.pubsub.v1.PubsubMessage.Builder,
                com.google.pubsub.v1.PubsubMessageOrBuilder>(
                getMessage(), getParentForChildren(), isClean());
        message_ = null;
      }
      return messageBuilder_;
    }

    private int deliveryAttempt_;

    /**
     *
     *
     * <pre>
     * Optional. The approximate number of times that Pub/Sub has attempted to
     * deliver the associated message to a subscriber.
     *
     * More precisely, this is 1 + (number of NACKs) +
     * (number of ack_deadline exceeds) for this message.
     *
     * A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
     * exceeds event is whenever a message is not acknowledged within
     * ack_deadline. Note that ack_deadline is initially
     * Subscription.ackDeadlineSeconds, but may get extended automatically by
     * the client library.
     *
     * Upon the first delivery of a given message, `delivery_attempt` will have a
     * value of 1. The value is calculated at best effort and is approximate.
     *
     * If a DeadLetterPolicy is not set on the subscription, this will be 0.
     * </pre>
     *
     * <code>int32 delivery_attempt = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return The deliveryAttempt.
     */
    @java.lang.Override
    public int getDeliveryAttempt() {
      return deliveryAttempt_;
    }

    /**
     *
     *
     * <pre>
     * Optional. The approximate number of times that Pub/Sub has attempted to
     * deliver the associated message to a subscriber.
     *
     * More precisely, this is 1 + (number of NACKs) +
     * (number of ack_deadline exceeds) for this message.
     *
     * A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
     * exceeds event is whenever a message is not acknowledged within
     * ack_deadline. Note that ack_deadline is initially
     * Subscription.ackDeadlineSeconds, but may get extended automatically by
     * the client library.
     *
     * Upon the first delivery of a given message, `delivery_attempt` will have a
     * value of 1. The value is calculated at best effort and is approximate.
     *
     * If a DeadLetterPolicy is not set on the subscription, this will be 0.
     * </pre>
     *
     * <code>int32 delivery_attempt = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @param value The deliveryAttempt to set.
     * @return This builder for chaining.
     */
    public Builder setDeliveryAttempt(int value) {

      deliveryAttempt_ = value;
      bitField0_ |= 0x00000004;
      onChanged();
      return this;
    }

    /**
     *
     *
     * <pre>
     * Optional. The approximate number of times that Pub/Sub has attempted to
     * deliver the associated message to a subscriber.
     *
     * More precisely, this is 1 + (number of NACKs) +
     * (number of ack_deadline exceeds) for this message.
     *
     * A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
     * exceeds event is whenever a message is not acknowledged within
     * ack_deadline. Note that ack_deadline is initially
     * Subscription.ackDeadlineSeconds, but may get extended automatically by
     * the client library.
     *
     * Upon the first delivery of a given message, `delivery_attempt` will have a
     * value of 1. The value is calculated at best effort and is approximate.
     *
     * If a DeadLetterPolicy is not set on the subscription, this will be 0.
     * </pre>
     *
     * <code>int32 delivery_attempt = 3 [(.google.api.field_behavior) = OPTIONAL];</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearDeliveryAttempt() {
      bitField0_ = (bitField0_ & ~0x00000004);
      deliveryAttempt_ = 0;
      onChanged();
      return this;
    }

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

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

    // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ReceivedMessage)
  }

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

  static {
    DEFAULT_INSTANCE = new com.google.pubsub.v1.ReceivedMessage();
  }

  public static com.google.pubsub.v1.ReceivedMessage getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<ReceivedMessage> PARSER =
      new com.google.protobuf.AbstractParser<ReceivedMessage>() {
        @java.lang.Override
        public ReceivedMessage parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
