/*
 * Copyright 2019 The Grafeas Authors. All rights reserved.
 *
 * 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: grafeas/v1/common.proto

package io.grafeas.v1;

/**
 *
 *
 * <pre>
 * MUST match
 * https://github.com/secure-systems-lab/dsse/blob/master/envelope.proto. An
 * authenticated message of arbitrary type.
 * </pre>
 *
 * Protobuf type {@code grafeas.v1.Envelope}
 */
public final class Envelope extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:grafeas.v1.Envelope)
    EnvelopeOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use Envelope.newBuilder() to construct.
  private Envelope(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private Envelope() {
    payload_ = com.google.protobuf.ByteString.EMPTY;
    payloadType_ = "";
    signatures_ = java.util.Collections.emptyList();
  }

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

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return io.grafeas.v1.Common.internal_static_grafeas_v1_Envelope_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return io.grafeas.v1.Common.internal_static_grafeas_v1_Envelope_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            io.grafeas.v1.Envelope.class, io.grafeas.v1.Envelope.Builder.class);
  }

  public static final int PAYLOAD_FIELD_NUMBER = 1;
  private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY;
  /**
   * <code>bytes payload = 1;</code>
   *
   * @return The payload.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getPayload() {
    return payload_;
  }

  public static final int PAYLOAD_TYPE_FIELD_NUMBER = 2;

  @SuppressWarnings("serial")
  private volatile java.lang.Object payloadType_ = "";
  /**
   * <code>string payload_type = 2;</code>
   *
   * @return The payloadType.
   */
  @java.lang.Override
  public java.lang.String getPayloadType() {
    java.lang.Object ref = payloadType_;
    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();
      payloadType_ = s;
      return s;
    }
  }
  /**
   * <code>string payload_type = 2;</code>
   *
   * @return The bytes for payloadType.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getPayloadTypeBytes() {
    java.lang.Object ref = payloadType_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      payloadType_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int SIGNATURES_FIELD_NUMBER = 3;

  @SuppressWarnings("serial")
  private java.util.List<io.grafeas.v1.EnvelopeSignature> signatures_;
  /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
  @java.lang.Override
  public java.util.List<io.grafeas.v1.EnvelopeSignature> getSignaturesList() {
    return signatures_;
  }
  /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
  @java.lang.Override
  public java.util.List<? extends io.grafeas.v1.EnvelopeSignatureOrBuilder>
      getSignaturesOrBuilderList() {
    return signatures_;
  }
  /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
  @java.lang.Override
  public int getSignaturesCount() {
    return signatures_.size();
  }
  /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
  @java.lang.Override
  public io.grafeas.v1.EnvelopeSignature getSignatures(int index) {
    return signatures_.get(index);
  }
  /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
  @java.lang.Override
  public io.grafeas.v1.EnvelopeSignatureOrBuilder getSignaturesOrBuilder(int index) {
    return signatures_.get(index);
  }

  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 (!payload_.isEmpty()) {
      output.writeBytes(1, payload_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(payloadType_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, payloadType_);
    }
    for (int i = 0; i < signatures_.size(); i++) {
      output.writeMessage(3, signatures_.get(i));
    }
    getUnknownFields().writeTo(output);
  }

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

    size = 0;
    if (!payload_.isEmpty()) {
      size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, payload_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(payloadType_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, payloadType_);
    }
    for (int i = 0; i < signatures_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, signatures_.get(i));
    }
    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 io.grafeas.v1.Envelope)) {
      return super.equals(obj);
    }
    io.grafeas.v1.Envelope other = (io.grafeas.v1.Envelope) obj;

    if (!getPayload().equals(other.getPayload())) return false;
    if (!getPayloadType().equals(other.getPayloadType())) return false;
    if (!getSignaturesList().equals(other.getSignaturesList())) 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) + PAYLOAD_FIELD_NUMBER;
    hash = (53 * hash) + getPayload().hashCode();
    hash = (37 * hash) + PAYLOAD_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + getPayloadType().hashCode();
    if (getSignaturesCount() > 0) {
      hash = (37 * hash) + SIGNATURES_FIELD_NUMBER;
      hash = (53 * hash) + getSignaturesList().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

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

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

  public static io.grafeas.v1.Envelope parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static io.grafeas.v1.Envelope parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static io.grafeas.v1.Envelope parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

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

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

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

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

  public static io.grafeas.v1.Envelope 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(io.grafeas.v1.Envelope 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>
   * MUST match
   * https://github.com/secure-systems-lab/dsse/blob/master/envelope.proto. An
   * authenticated message of arbitrary type.
   * </pre>
   *
   * Protobuf type {@code grafeas.v1.Envelope}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:grafeas.v1.Envelope)
      io.grafeas.v1.EnvelopeOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return io.grafeas.v1.Common.internal_static_grafeas_v1_Envelope_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return io.grafeas.v1.Common.internal_static_grafeas_v1_Envelope_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              io.grafeas.v1.Envelope.class, io.grafeas.v1.Envelope.Builder.class);
    }

    // Construct using io.grafeas.v1.Envelope.newBuilder()
    private Builder() {}

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      bitField0_ = 0;
      payload_ = com.google.protobuf.ByteString.EMPTY;
      payloadType_ = "";
      if (signaturesBuilder_ == null) {
        signatures_ = java.util.Collections.emptyList();
      } else {
        signatures_ = null;
        signaturesBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000004);
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return io.grafeas.v1.Common.internal_static_grafeas_v1_Envelope_descriptor;
    }

    @java.lang.Override
    public io.grafeas.v1.Envelope getDefaultInstanceForType() {
      return io.grafeas.v1.Envelope.getDefaultInstance();
    }

    @java.lang.Override
    public io.grafeas.v1.Envelope build() {
      io.grafeas.v1.Envelope result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public io.grafeas.v1.Envelope buildPartial() {
      io.grafeas.v1.Envelope result = new io.grafeas.v1.Envelope(this);
      buildPartialRepeatedFields(result);
      if (bitField0_ != 0) {
        buildPartial0(result);
      }
      onBuilt();
      return result;
    }

    private void buildPartialRepeatedFields(io.grafeas.v1.Envelope result) {
      if (signaturesBuilder_ == null) {
        if (((bitField0_ & 0x00000004) != 0)) {
          signatures_ = java.util.Collections.unmodifiableList(signatures_);
          bitField0_ = (bitField0_ & ~0x00000004);
        }
        result.signatures_ = signatures_;
      } else {
        result.signatures_ = signaturesBuilder_.build();
      }
    }

    private void buildPartial0(io.grafeas.v1.Envelope result) {
      int from_bitField0_ = bitField0_;
      if (((from_bitField0_ & 0x00000001) != 0)) {
        result.payload_ = payload_;
      }
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.payloadType_ = payloadType_;
      }
    }

    @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 io.grafeas.v1.Envelope) {
        return mergeFrom((io.grafeas.v1.Envelope) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(io.grafeas.v1.Envelope other) {
      if (other == io.grafeas.v1.Envelope.getDefaultInstance()) return this;
      if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) {
        setPayload(other.getPayload());
      }
      if (!other.getPayloadType().isEmpty()) {
        payloadType_ = other.payloadType_;
        bitField0_ |= 0x00000002;
        onChanged();
      }
      if (signaturesBuilder_ == null) {
        if (!other.signatures_.isEmpty()) {
          if (signatures_.isEmpty()) {
            signatures_ = other.signatures_;
            bitField0_ = (bitField0_ & ~0x00000004);
          } else {
            ensureSignaturesIsMutable();
            signatures_.addAll(other.signatures_);
          }
          onChanged();
        }
      } else {
        if (!other.signatures_.isEmpty()) {
          if (signaturesBuilder_.isEmpty()) {
            signaturesBuilder_.dispose();
            signaturesBuilder_ = null;
            signatures_ = other.signatures_;
            bitField0_ = (bitField0_ & ~0x00000004);
            signaturesBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getSignaturesFieldBuilder()
                    : null;
          } else {
            signaturesBuilder_.addAllMessages(other.signatures_);
          }
        }
      }
      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:
              {
                payload_ = input.readBytes();
                bitField0_ |= 0x00000001;
                break;
              } // case 10
            case 18:
              {
                payloadType_ = input.readStringRequireUtf8();
                bitField0_ |= 0x00000002;
                break;
              } // case 18
            case 26:
              {
                io.grafeas.v1.EnvelopeSignature m =
                    input.readMessage(io.grafeas.v1.EnvelopeSignature.parser(), extensionRegistry);
                if (signaturesBuilder_ == null) {
                  ensureSignaturesIsMutable();
                  signatures_.add(m);
                } else {
                  signaturesBuilder_.addMessage(m);
                }
                break;
              } // case 26
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY;
    /**
     * <code>bytes payload = 1;</code>
     *
     * @return The payload.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString getPayload() {
      return payload_;
    }
    /**
     * <code>bytes payload = 1;</code>
     *
     * @param value The payload to set.
     * @return This builder for chaining.
     */
    public Builder setPayload(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      payload_ = value;
      bitField0_ |= 0x00000001;
      onChanged();
      return this;
    }
    /**
     * <code>bytes payload = 1;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearPayload() {
      bitField0_ = (bitField0_ & ~0x00000001);
      payload_ = getDefaultInstance().getPayload();
      onChanged();
      return this;
    }

    private java.lang.Object payloadType_ = "";
    /**
     * <code>string payload_type = 2;</code>
     *
     * @return The payloadType.
     */
    public java.lang.String getPayloadType() {
      java.lang.Object ref = payloadType_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        payloadType_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <code>string payload_type = 2;</code>
     *
     * @return The bytes for payloadType.
     */
    public com.google.protobuf.ByteString getPayloadTypeBytes() {
      java.lang.Object ref = payloadType_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        payloadType_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <code>string payload_type = 2;</code>
     *
     * @param value The payloadType to set.
     * @return This builder for chaining.
     */
    public Builder setPayloadType(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      payloadType_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }
    /**
     * <code>string payload_type = 2;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearPayloadType() {
      payloadType_ = getDefaultInstance().getPayloadType();
      bitField0_ = (bitField0_ & ~0x00000002);
      onChanged();
      return this;
    }
    /**
     * <code>string payload_type = 2;</code>
     *
     * @param value The bytes for payloadType to set.
     * @return This builder for chaining.
     */
    public Builder setPayloadTypeBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      payloadType_ = value;
      bitField0_ |= 0x00000002;
      onChanged();
      return this;
    }

    private java.util.List<io.grafeas.v1.EnvelopeSignature> signatures_ =
        java.util.Collections.emptyList();

    private void ensureSignaturesIsMutable() {
      if (!((bitField0_ & 0x00000004) != 0)) {
        signatures_ = new java.util.ArrayList<io.grafeas.v1.EnvelopeSignature>(signatures_);
        bitField0_ |= 0x00000004;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            io.grafeas.v1.EnvelopeSignature,
            io.grafeas.v1.EnvelopeSignature.Builder,
            io.grafeas.v1.EnvelopeSignatureOrBuilder>
        signaturesBuilder_;

    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public java.util.List<io.grafeas.v1.EnvelopeSignature> getSignaturesList() {
      if (signaturesBuilder_ == null) {
        return java.util.Collections.unmodifiableList(signatures_);
      } else {
        return signaturesBuilder_.getMessageList();
      }
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public int getSignaturesCount() {
      if (signaturesBuilder_ == null) {
        return signatures_.size();
      } else {
        return signaturesBuilder_.getCount();
      }
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public io.grafeas.v1.EnvelopeSignature getSignatures(int index) {
      if (signaturesBuilder_ == null) {
        return signatures_.get(index);
      } else {
        return signaturesBuilder_.getMessage(index);
      }
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder setSignatures(int index, io.grafeas.v1.EnvelopeSignature value) {
      if (signaturesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureSignaturesIsMutable();
        signatures_.set(index, value);
        onChanged();
      } else {
        signaturesBuilder_.setMessage(index, value);
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder setSignatures(
        int index, io.grafeas.v1.EnvelopeSignature.Builder builderForValue) {
      if (signaturesBuilder_ == null) {
        ensureSignaturesIsMutable();
        signatures_.set(index, builderForValue.build());
        onChanged();
      } else {
        signaturesBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder addSignatures(io.grafeas.v1.EnvelopeSignature value) {
      if (signaturesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureSignaturesIsMutable();
        signatures_.add(value);
        onChanged();
      } else {
        signaturesBuilder_.addMessage(value);
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder addSignatures(int index, io.grafeas.v1.EnvelopeSignature value) {
      if (signaturesBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureSignaturesIsMutable();
        signatures_.add(index, value);
        onChanged();
      } else {
        signaturesBuilder_.addMessage(index, value);
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder addSignatures(io.grafeas.v1.EnvelopeSignature.Builder builderForValue) {
      if (signaturesBuilder_ == null) {
        ensureSignaturesIsMutable();
        signatures_.add(builderForValue.build());
        onChanged();
      } else {
        signaturesBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder addSignatures(
        int index, io.grafeas.v1.EnvelopeSignature.Builder builderForValue) {
      if (signaturesBuilder_ == null) {
        ensureSignaturesIsMutable();
        signatures_.add(index, builderForValue.build());
        onChanged();
      } else {
        signaturesBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder addAllSignatures(
        java.lang.Iterable<? extends io.grafeas.v1.EnvelopeSignature> values) {
      if (signaturesBuilder_ == null) {
        ensureSignaturesIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, signatures_);
        onChanged();
      } else {
        signaturesBuilder_.addAllMessages(values);
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder clearSignatures() {
      if (signaturesBuilder_ == null) {
        signatures_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000004);
        onChanged();
      } else {
        signaturesBuilder_.clear();
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public Builder removeSignatures(int index) {
      if (signaturesBuilder_ == null) {
        ensureSignaturesIsMutable();
        signatures_.remove(index);
        onChanged();
      } else {
        signaturesBuilder_.remove(index);
      }
      return this;
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public io.grafeas.v1.EnvelopeSignature.Builder getSignaturesBuilder(int index) {
      return getSignaturesFieldBuilder().getBuilder(index);
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public io.grafeas.v1.EnvelopeSignatureOrBuilder getSignaturesOrBuilder(int index) {
      if (signaturesBuilder_ == null) {
        return signatures_.get(index);
      } else {
        return signaturesBuilder_.getMessageOrBuilder(index);
      }
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public java.util.List<? extends io.grafeas.v1.EnvelopeSignatureOrBuilder>
        getSignaturesOrBuilderList() {
      if (signaturesBuilder_ != null) {
        return signaturesBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(signatures_);
      }
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public io.grafeas.v1.EnvelopeSignature.Builder addSignaturesBuilder() {
      return getSignaturesFieldBuilder()
          .addBuilder(io.grafeas.v1.EnvelopeSignature.getDefaultInstance());
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public io.grafeas.v1.EnvelopeSignature.Builder addSignaturesBuilder(int index) {
      return getSignaturesFieldBuilder()
          .addBuilder(index, io.grafeas.v1.EnvelopeSignature.getDefaultInstance());
    }
    /** <code>repeated .grafeas.v1.EnvelopeSignature signatures = 3;</code> */
    public java.util.List<io.grafeas.v1.EnvelopeSignature.Builder> getSignaturesBuilderList() {
      return getSignaturesFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            io.grafeas.v1.EnvelopeSignature,
            io.grafeas.v1.EnvelopeSignature.Builder,
            io.grafeas.v1.EnvelopeSignatureOrBuilder>
        getSignaturesFieldBuilder() {
      if (signaturesBuilder_ == null) {
        signaturesBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                io.grafeas.v1.EnvelopeSignature,
                io.grafeas.v1.EnvelopeSignature.Builder,
                io.grafeas.v1.EnvelopeSignatureOrBuilder>(
                signatures_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean());
        signatures_ = null;
      }
      return signaturesBuilder_;
    }

    @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:grafeas.v1.Envelope)
  }

  // @@protoc_insertion_point(class_scope:grafeas.v1.Envelope)
  private static final io.grafeas.v1.Envelope DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new io.grafeas.v1.Envelope();
  }

  public static io.grafeas.v1.Envelope getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

  @java.lang.Override
  public io.grafeas.v1.Envelope getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
