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

package io.grafeas.v1beta1.build;

/**
 *
 *
 * <pre>
 * Message encapsulating the signature of the verified build.
 * </pre>
 *
 * Protobuf type {@code grafeas.v1beta1.build.BuildSignature}
 */
public final class BuildSignature extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:grafeas.v1beta1.build.BuildSignature)
    BuildSignatureOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use BuildSignature.newBuilder() to construct.
  private BuildSignature(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private BuildSignature() {
    publicKey_ = "";
    signature_ = com.google.protobuf.ByteString.EMPTY;
    keyId_ = "";
    keyType_ = 0;
  }

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

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

  private BuildSignature(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          case 10:
            {
              java.lang.String s = input.readStringRequireUtf8();

              publicKey_ = s;
              break;
            }
          case 18:
            {
              signature_ = input.readBytes();
              break;
            }
          case 26:
            {
              java.lang.String s = input.readStringRequireUtf8();

              keyId_ = s;
              break;
            }
          case 32:
            {
              int rawValue = input.readEnum();

              keyType_ = rawValue;
              break;
            }
          default:
            {
              if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
                done = true;
              }
              break;
            }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this);
    } finally {
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return io.grafeas.v1beta1.build.BuildOuterClass
        .internal_static_grafeas_v1beta1_build_BuildSignature_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return io.grafeas.v1beta1.build.BuildOuterClass
        .internal_static_grafeas_v1beta1_build_BuildSignature_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            io.grafeas.v1beta1.build.BuildSignature.class,
            io.grafeas.v1beta1.build.BuildSignature.Builder.class);
  }

  /**
   *
   *
   * <pre>
   * Public key formats.
   * </pre>
   *
   * Protobuf enum {@code grafeas.v1beta1.build.BuildSignature.KeyType}
   */
  public enum KeyType implements com.google.protobuf.ProtocolMessageEnum {
    /**
     *
     *
     * <pre>
     * `KeyType` is not set.
     * </pre>
     *
     * <code>KEY_TYPE_UNSPECIFIED = 0;</code>
     */
    KEY_TYPE_UNSPECIFIED(0),
    /**
     *
     *
     * <pre>
     * `PGP ASCII Armored` public key.
     * </pre>
     *
     * <code>PGP_ASCII_ARMORED = 1;</code>
     */
    PGP_ASCII_ARMORED(1),
    /**
     *
     *
     * <pre>
     * `PKIX PEM` public key.
     * </pre>
     *
     * <code>PKIX_PEM = 2;</code>
     */
    PKIX_PEM(2),
    UNRECOGNIZED(-1),
    ;

    /**
     *
     *
     * <pre>
     * `KeyType` is not set.
     * </pre>
     *
     * <code>KEY_TYPE_UNSPECIFIED = 0;</code>
     */
    public static final int KEY_TYPE_UNSPECIFIED_VALUE = 0;
    /**
     *
     *
     * <pre>
     * `PGP ASCII Armored` public key.
     * </pre>
     *
     * <code>PGP_ASCII_ARMORED = 1;</code>
     */
    public static final int PGP_ASCII_ARMORED_VALUE = 1;
    /**
     *
     *
     * <pre>
     * `PKIX PEM` public key.
     * </pre>
     *
     * <code>PKIX_PEM = 2;</code>
     */
    public static final int PKIX_PEM_VALUE = 2;

    public final int getNumber() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalArgumentException(
            "Can't get the number of an unknown enum value.");
      }
      return value;
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static KeyType valueOf(int value) {
      return forNumber(value);
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     */
    public static KeyType forNumber(int value) {
      switch (value) {
        case 0:
          return KEY_TYPE_UNSPECIFIED;
        case 1:
          return PGP_ASCII_ARMORED;
        case 2:
          return PKIX_PEM;
        default:
          return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<KeyType> internalGetValueMap() {
      return internalValueMap;
    }

    private static final com.google.protobuf.Internal.EnumLiteMap<KeyType> internalValueMap =
        new com.google.protobuf.Internal.EnumLiteMap<KeyType>() {
          public KeyType findValueByNumber(int number) {
            return KeyType.forNumber(number);
          }
        };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalStateException(
            "Can't get the descriptor of an unrecognized enum value.");
      }
      return getDescriptor().getValues().get(ordinal());
    }

    public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
      return getDescriptor();
    }

    public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
      return io.grafeas.v1beta1.build.BuildSignature.getDescriptor().getEnumTypes().get(0);
    }

    private static final KeyType[] VALUES = values();

    public static KeyType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
      }
      if (desc.getIndex() == -1) {
        return UNRECOGNIZED;
      }
      return VALUES[desc.getIndex()];
    }

    private final int value;

    private KeyType(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:grafeas.v1beta1.build.BuildSignature.KeyType)
  }

  public static final int PUBLIC_KEY_FIELD_NUMBER = 1;
  private volatile java.lang.Object publicKey_;
  /**
   *
   *
   * <pre>
   * Public key of the builder which can be used to verify that the related
   * findings are valid and unchanged. If `key_type` is empty, this defaults
   * to PEM encoded public keys.
   * This field may be empty if `key_id` references an external key.
   * For Cloud Build based signatures, this is a PEM encoded public
   * key. To verify the Cloud Build signature, place the contents of
   * this field into a file (public.pem). The signature field is base64-decoded
   * into its binary representation in signature.bin, and the provenance bytes
   * from `BuildDetails` are base64-decoded into a binary representation in
   * signed.bin. OpenSSL can then verify the signature:
   * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
   * </pre>
   *
   * <code>string public_key = 1;</code>
   *
   * @return The publicKey.
   */
  @java.lang.Override
  public java.lang.String getPublicKey() {
    java.lang.Object ref = publicKey_;
    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();
      publicKey_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * Public key of the builder which can be used to verify that the related
   * findings are valid and unchanged. If `key_type` is empty, this defaults
   * to PEM encoded public keys.
   * This field may be empty if `key_id` references an external key.
   * For Cloud Build based signatures, this is a PEM encoded public
   * key. To verify the Cloud Build signature, place the contents of
   * this field into a file (public.pem). The signature field is base64-decoded
   * into its binary representation in signature.bin, and the provenance bytes
   * from `BuildDetails` are base64-decoded into a binary representation in
   * signed.bin. OpenSSL can then verify the signature:
   * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
   * </pre>
   *
   * <code>string public_key = 1;</code>
   *
   * @return The bytes for publicKey.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getPublicKeyBytes() {
    java.lang.Object ref = publicKey_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      publicKey_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int SIGNATURE_FIELD_NUMBER = 2;
  private com.google.protobuf.ByteString signature_;
  /**
   *
   *
   * <pre>
   * Required. Signature of the related `BuildProvenance`. In JSON, this is
   * base-64 encoded.
   * </pre>
   *
   * <code>bytes signature = 2;</code>
   *
   * @return The signature.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getSignature() {
    return signature_;
  }

  public static final int KEY_ID_FIELD_NUMBER = 3;
  private volatile java.lang.Object keyId_;
  /**
   *
   *
   * <pre>
   * An ID for the key used to sign. This could be either an ID for the key
   * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
   * CN for a cert), or a reference to an external key (such as a reference to a
   * key in Cloud Key Management Service).
   * </pre>
   *
   * <code>string key_id = 3;</code>
   *
   * @return The keyId.
   */
  @java.lang.Override
  public java.lang.String getKeyId() {
    java.lang.Object ref = keyId_;
    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();
      keyId_ = s;
      return s;
    }
  }
  /**
   *
   *
   * <pre>
   * An ID for the key used to sign. This could be either an ID for the key
   * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
   * CN for a cert), or a reference to an external key (such as a reference to a
   * key in Cloud Key Management Service).
   * </pre>
   *
   * <code>string key_id = 3;</code>
   *
   * @return The bytes for keyId.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getKeyIdBytes() {
    java.lang.Object ref = keyId_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      keyId_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int KEY_TYPE_FIELD_NUMBER = 4;
  private int keyType_;
  /**
   *
   *
   * <pre>
   * The type of the key, either stored in `public_key` or referenced in
   * `key_id`.
   * </pre>
   *
   * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
   *
   * @return The enum numeric value on the wire for keyType.
   */
  @java.lang.Override
  public int getKeyTypeValue() {
    return keyType_;
  }
  /**
   *
   *
   * <pre>
   * The type of the key, either stored in `public_key` or referenced in
   * `key_id`.
   * </pre>
   *
   * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
   *
   * @return The keyType.
   */
  @java.lang.Override
  public io.grafeas.v1beta1.build.BuildSignature.KeyType getKeyType() {
    @SuppressWarnings("deprecation")
    io.grafeas.v1beta1.build.BuildSignature.KeyType result =
        io.grafeas.v1beta1.build.BuildSignature.KeyType.valueOf(keyType_);
    return result == null ? io.grafeas.v1beta1.build.BuildSignature.KeyType.UNRECOGNIZED : result;
  }

  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 (!getPublicKeyBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, publicKey_);
    }
    if (!signature_.isEmpty()) {
      output.writeBytes(2, signature_);
    }
    if (!getKeyIdBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 3, keyId_);
    }
    if (keyType_
        != io.grafeas.v1beta1.build.BuildSignature.KeyType.KEY_TYPE_UNSPECIFIED.getNumber()) {
      output.writeEnum(4, keyType_);
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    if (!getPublicKeyBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, publicKey_);
    }
    if (!signature_.isEmpty()) {
      size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, signature_);
    }
    if (!getKeyIdBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, keyId_);
    }
    if (keyType_
        != io.grafeas.v1beta1.build.BuildSignature.KeyType.KEY_TYPE_UNSPECIFIED.getNumber()) {
      size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, keyType_);
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof io.grafeas.v1beta1.build.BuildSignature)) {
      return super.equals(obj);
    }
    io.grafeas.v1beta1.build.BuildSignature other = (io.grafeas.v1beta1.build.BuildSignature) obj;

    if (!getPublicKey().equals(other.getPublicKey())) return false;
    if (!getSignature().equals(other.getSignature())) return false;
    if (!getKeyId().equals(other.getKeyId())) return false;
    if (keyType_ != other.keyType_) return false;
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + PUBLIC_KEY_FIELD_NUMBER;
    hash = (53 * hash) + getPublicKey().hashCode();
    hash = (37 * hash) + SIGNATURE_FIELD_NUMBER;
    hash = (53 * hash) + getSignature().hashCode();
    hash = (37 * hash) + KEY_ID_FIELD_NUMBER;
    hash = (53 * hash) + getKeyId().hashCode();
    hash = (37 * hash) + KEY_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + keyType_;
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

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

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

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

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

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

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

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

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

  public static io.grafeas.v1beta1.build.BuildSignature 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.v1beta1.build.BuildSignature 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>
   * Message encapsulating the signature of the verified build.
   * </pre>
   *
   * Protobuf type {@code grafeas.v1beta1.build.BuildSignature}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:grafeas.v1beta1.build.BuildSignature)
      io.grafeas.v1beta1.build.BuildSignatureOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return io.grafeas.v1beta1.build.BuildOuterClass
          .internal_static_grafeas_v1beta1_build_BuildSignature_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return io.grafeas.v1beta1.build.BuildOuterClass
          .internal_static_grafeas_v1beta1_build_BuildSignature_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              io.grafeas.v1beta1.build.BuildSignature.class,
              io.grafeas.v1beta1.build.BuildSignature.Builder.class);
    }

    // Construct using io.grafeas.v1beta1.build.BuildSignature.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

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

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

    @java.lang.Override
    public Builder clear() {
      super.clear();
      publicKey_ = "";

      signature_ = com.google.protobuf.ByteString.EMPTY;

      keyId_ = "";

      keyType_ = 0;

      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return io.grafeas.v1beta1.build.BuildOuterClass
          .internal_static_grafeas_v1beta1_build_BuildSignature_descriptor;
    }

    @java.lang.Override
    public io.grafeas.v1beta1.build.BuildSignature getDefaultInstanceForType() {
      return io.grafeas.v1beta1.build.BuildSignature.getDefaultInstance();
    }

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

    @java.lang.Override
    public io.grafeas.v1beta1.build.BuildSignature buildPartial() {
      io.grafeas.v1beta1.build.BuildSignature result =
          new io.grafeas.v1beta1.build.BuildSignature(this);
      result.publicKey_ = publicKey_;
      result.signature_ = signature_;
      result.keyId_ = keyId_;
      result.keyType_ = keyType_;
      onBuilt();
      return result;
    }

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

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

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

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

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

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

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof io.grafeas.v1beta1.build.BuildSignature) {
        return mergeFrom((io.grafeas.v1beta1.build.BuildSignature) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(io.grafeas.v1beta1.build.BuildSignature other) {
      if (other == io.grafeas.v1beta1.build.BuildSignature.getDefaultInstance()) return this;
      if (!other.getPublicKey().isEmpty()) {
        publicKey_ = other.publicKey_;
        onChanged();
      }
      if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) {
        setSignature(other.getSignature());
      }
      if (!other.getKeyId().isEmpty()) {
        keyId_ = other.keyId_;
        onChanged();
      }
      if (other.keyType_ != 0) {
        setKeyTypeValue(other.getKeyTypeValue());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

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

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      io.grafeas.v1beta1.build.BuildSignature parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (io.grafeas.v1beta1.build.BuildSignature) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private java.lang.Object publicKey_ = "";
    /**
     *
     *
     * <pre>
     * Public key of the builder which can be used to verify that the related
     * findings are valid and unchanged. If `key_type` is empty, this defaults
     * to PEM encoded public keys.
     * This field may be empty if `key_id` references an external key.
     * For Cloud Build based signatures, this is a PEM encoded public
     * key. To verify the Cloud Build signature, place the contents of
     * this field into a file (public.pem). The signature field is base64-decoded
     * into its binary representation in signature.bin, and the provenance bytes
     * from `BuildDetails` are base64-decoded into a binary representation in
     * signed.bin. OpenSSL can then verify the signature:
     * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
     * </pre>
     *
     * <code>string public_key = 1;</code>
     *
     * @return The publicKey.
     */
    public java.lang.String getPublicKey() {
      java.lang.Object ref = publicKey_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        publicKey_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Public key of the builder which can be used to verify that the related
     * findings are valid and unchanged. If `key_type` is empty, this defaults
     * to PEM encoded public keys.
     * This field may be empty if `key_id` references an external key.
     * For Cloud Build based signatures, this is a PEM encoded public
     * key. To verify the Cloud Build signature, place the contents of
     * this field into a file (public.pem). The signature field is base64-decoded
     * into its binary representation in signature.bin, and the provenance bytes
     * from `BuildDetails` are base64-decoded into a binary representation in
     * signed.bin. OpenSSL can then verify the signature:
     * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
     * </pre>
     *
     * <code>string public_key = 1;</code>
     *
     * @return The bytes for publicKey.
     */
    public com.google.protobuf.ByteString getPublicKeyBytes() {
      java.lang.Object ref = publicKey_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        publicKey_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * Public key of the builder which can be used to verify that the related
     * findings are valid and unchanged. If `key_type` is empty, this defaults
     * to PEM encoded public keys.
     * This field may be empty if `key_id` references an external key.
     * For Cloud Build based signatures, this is a PEM encoded public
     * key. To verify the Cloud Build signature, place the contents of
     * this field into a file (public.pem). The signature field is base64-decoded
     * into its binary representation in signature.bin, and the provenance bytes
     * from `BuildDetails` are base64-decoded into a binary representation in
     * signed.bin. OpenSSL can then verify the signature:
     * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
     * </pre>
     *
     * <code>string public_key = 1;</code>
     *
     * @param value The publicKey to set.
     * @return This builder for chaining.
     */
    public Builder setPublicKey(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      publicKey_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Public key of the builder which can be used to verify that the related
     * findings are valid and unchanged. If `key_type` is empty, this defaults
     * to PEM encoded public keys.
     * This field may be empty if `key_id` references an external key.
     * For Cloud Build based signatures, this is a PEM encoded public
     * key. To verify the Cloud Build signature, place the contents of
     * this field into a file (public.pem). The signature field is base64-decoded
     * into its binary representation in signature.bin, and the provenance bytes
     * from `BuildDetails` are base64-decoded into a binary representation in
     * signed.bin. OpenSSL can then verify the signature:
     * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
     * </pre>
     *
     * <code>string public_key = 1;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearPublicKey() {

      publicKey_ = getDefaultInstance().getPublicKey();
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Public key of the builder which can be used to verify that the related
     * findings are valid and unchanged. If `key_type` is empty, this defaults
     * to PEM encoded public keys.
     * This field may be empty if `key_id` references an external key.
     * For Cloud Build based signatures, this is a PEM encoded public
     * key. To verify the Cloud Build signature, place the contents of
     * this field into a file (public.pem). The signature field is base64-decoded
     * into its binary representation in signature.bin, and the provenance bytes
     * from `BuildDetails` are base64-decoded into a binary representation in
     * signed.bin. OpenSSL can then verify the signature:
     * `openssl sha256 -verify public.pem -signature signature.bin signed.bin`
     * </pre>
     *
     * <code>string public_key = 1;</code>
     *
     * @param value The bytes for publicKey to set.
     * @return This builder for chaining.
     */
    public Builder setPublicKeyBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      publicKey_ = value;
      onChanged();
      return this;
    }

    private com.google.protobuf.ByteString signature_ = com.google.protobuf.ByteString.EMPTY;
    /**
     *
     *
     * <pre>
     * Required. Signature of the related `BuildProvenance`. In JSON, this is
     * base-64 encoded.
     * </pre>
     *
     * <code>bytes signature = 2;</code>
     *
     * @return The signature.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString getSignature() {
      return signature_;
    }
    /**
     *
     *
     * <pre>
     * Required. Signature of the related `BuildProvenance`. In JSON, this is
     * base-64 encoded.
     * </pre>
     *
     * <code>bytes signature = 2;</code>
     *
     * @param value The signature to set.
     * @return This builder for chaining.
     */
    public Builder setSignature(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }

      signature_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * Required. Signature of the related `BuildProvenance`. In JSON, this is
     * base-64 encoded.
     * </pre>
     *
     * <code>bytes signature = 2;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearSignature() {

      signature_ = getDefaultInstance().getSignature();
      onChanged();
      return this;
    }

    private java.lang.Object keyId_ = "";
    /**
     *
     *
     * <pre>
     * An ID for the key used to sign. This could be either an ID for the key
     * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
     * CN for a cert), or a reference to an external key (such as a reference to a
     * key in Cloud Key Management Service).
     * </pre>
     *
     * <code>string key_id = 3;</code>
     *
     * @return The keyId.
     */
    public java.lang.String getKeyId() {
      java.lang.Object ref = keyId_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        keyId_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * An ID for the key used to sign. This could be either an ID for the key
     * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
     * CN for a cert), or a reference to an external key (such as a reference to a
     * key in Cloud Key Management Service).
     * </pre>
     *
     * <code>string key_id = 3;</code>
     *
     * @return The bytes for keyId.
     */
    public com.google.protobuf.ByteString getKeyIdBytes() {
      java.lang.Object ref = keyId_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        keyId_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     * <pre>
     * An ID for the key used to sign. This could be either an ID for the key
     * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
     * CN for a cert), or a reference to an external key (such as a reference to a
     * key in Cloud Key Management Service).
     * </pre>
     *
     * <code>string key_id = 3;</code>
     *
     * @param value The keyId to set.
     * @return This builder for chaining.
     */
    public Builder setKeyId(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      keyId_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * An ID for the key used to sign. This could be either an ID for the key
     * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
     * CN for a cert), or a reference to an external key (such as a reference to a
     * key in Cloud Key Management Service).
     * </pre>
     *
     * <code>string key_id = 3;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearKeyId() {

      keyId_ = getDefaultInstance().getKeyId();
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * An ID for the key used to sign. This could be either an ID for the key
     * stored in `public_key` (such as the ID or fingerprint for a PGP key, or the
     * CN for a cert), or a reference to an external key (such as a reference to a
     * key in Cloud Key Management Service).
     * </pre>
     *
     * <code>string key_id = 3;</code>
     *
     * @param value The bytes for keyId to set.
     * @return This builder for chaining.
     */
    public Builder setKeyIdBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      keyId_ = value;
      onChanged();
      return this;
    }

    private int keyType_ = 0;
    /**
     *
     *
     * <pre>
     * The type of the key, either stored in `public_key` or referenced in
     * `key_id`.
     * </pre>
     *
     * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
     *
     * @return The enum numeric value on the wire for keyType.
     */
    @java.lang.Override
    public int getKeyTypeValue() {
      return keyType_;
    }
    /**
     *
     *
     * <pre>
     * The type of the key, either stored in `public_key` or referenced in
     * `key_id`.
     * </pre>
     *
     * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
     *
     * @param value The enum numeric value on the wire for keyType to set.
     * @return This builder for chaining.
     */
    public Builder setKeyTypeValue(int value) {

      keyType_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The type of the key, either stored in `public_key` or referenced in
     * `key_id`.
     * </pre>
     *
     * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
     *
     * @return The keyType.
     */
    @java.lang.Override
    public io.grafeas.v1beta1.build.BuildSignature.KeyType getKeyType() {
      @SuppressWarnings("deprecation")
      io.grafeas.v1beta1.build.BuildSignature.KeyType result =
          io.grafeas.v1beta1.build.BuildSignature.KeyType.valueOf(keyType_);
      return result == null ? io.grafeas.v1beta1.build.BuildSignature.KeyType.UNRECOGNIZED : result;
    }
    /**
     *
     *
     * <pre>
     * The type of the key, either stored in `public_key` or referenced in
     * `key_id`.
     * </pre>
     *
     * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
     *
     * @param value The keyType to set.
     * @return This builder for chaining.
     */
    public Builder setKeyType(io.grafeas.v1beta1.build.BuildSignature.KeyType value) {
      if (value == null) {
        throw new NullPointerException();
      }

      keyType_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *
     *
     * <pre>
     * The type of the key, either stored in `public_key` or referenced in
     * `key_id`.
     * </pre>
     *
     * <code>.grafeas.v1beta1.build.BuildSignature.KeyType key_type = 4;</code>
     *
     * @return This builder for chaining.
     */
    public Builder clearKeyType() {

      keyType_ = 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:grafeas.v1beta1.build.BuildSignature)
  }

  // @@protoc_insertion_point(class_scope:grafeas.v1beta1.build.BuildSignature)
  private static final io.grafeas.v1beta1.build.BuildSignature DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new io.grafeas.v1beta1.build.BuildSignature();
  }

  public static io.grafeas.v1beta1.build.BuildSignature getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  @java.lang.Override
  public io.grafeas.v1beta1.build.BuildSignature getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}
