// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/bigquery/connection/v1/connection.proto

package com.google.cloud.bigquery.connection.v1;

/**
 * <pre>
 * Connection properties specific to the Cloud SQL.
 * </pre>
 *
 * Protobuf type {@code google.cloud.bigquery.connection.v1.CloudSqlProperties}
 */
public final class CloudSqlProperties extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.cloud.bigquery.connection.v1.CloudSqlProperties)
    CloudSqlPropertiesOrBuilder {
private static final long serialVersionUID = 0L;
  // Use CloudSqlProperties.newBuilder() to construct.
  private CloudSqlProperties(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private CloudSqlProperties() {
    instanceId_ = "";
    database_ = "";
    type_ = 0;
  }

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

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private CloudSqlProperties(
      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();

            instanceId_ = s;
            break;
          }
          case 18: {
            java.lang.String s = input.readStringRequireUtf8();

            database_ = s;
            break;
          }
          case 24: {
            int rawValue = input.readEnum();

            type_ = rawValue;
            break;
          }
          case 34: {
            com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder subBuilder = null;
            if (credential_ != null) {
              subBuilder = credential_.toBuilder();
            }
            credential_ = input.readMessage(com.google.cloud.bigquery.connection.v1.CloudSqlCredential.parser(), extensionRegistry);
            if (subBuilder != null) {
              subBuilder.mergeFrom(credential_);
              credential_ = subBuilder.buildPartial();
            }

            break;
          }
          default: {
            if (!parseUnknownField(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.cloud.bigquery.connection.v1.ConnectionOuterClass.internal_static_google_cloud_bigquery_connection_v1_CloudSqlProperties_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.bigquery.connection.v1.ConnectionOuterClass.internal_static_google_cloud_bigquery_connection_v1_CloudSqlProperties_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.bigquery.connection.v1.CloudSqlProperties.class, com.google.cloud.bigquery.connection.v1.CloudSqlProperties.Builder.class);
  }

  /**
   * <pre>
   * Supported Cloud SQL database types.
   * </pre>
   *
   * Protobuf enum {@code google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType}
   */
  public enum DatabaseType
      implements com.google.protobuf.ProtocolMessageEnum {
    /**
     * <pre>
     * Unspecified database type.
     * </pre>
     *
     * <code>DATABASE_TYPE_UNSPECIFIED = 0;</code>
     */
    DATABASE_TYPE_UNSPECIFIED(0),
    /**
     * <pre>
     * Cloud SQL for PostgreSQL.
     * </pre>
     *
     * <code>POSTGRES = 1;</code>
     */
    POSTGRES(1),
    /**
     * <pre>
     * Cloud SQL for MySQL.
     * </pre>
     *
     * <code>MYSQL = 2;</code>
     */
    MYSQL(2),
    UNRECOGNIZED(-1),
    ;

    /**
     * <pre>
     * Unspecified database type.
     * </pre>
     *
     * <code>DATABASE_TYPE_UNSPECIFIED = 0;</code>
     */
    public static final int DATABASE_TYPE_UNSPECIFIED_VALUE = 0;
    /**
     * <pre>
     * Cloud SQL for PostgreSQL.
     * </pre>
     *
     * <code>POSTGRES = 1;</code>
     */
    public static final int POSTGRES_VALUE = 1;
    /**
     * <pre>
     * Cloud SQL for MySQL.
     * </pre>
     *
     * <code>MYSQL = 2;</code>
     */
    public static final int MYSQL_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 DatabaseType 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 DatabaseType forNumber(int value) {
      switch (value) {
        case 0: return DATABASE_TYPE_UNSPECIFIED;
        case 1: return POSTGRES;
        case 2: return MYSQL;
        default: return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<DatabaseType>
        internalGetValueMap() {
      return internalValueMap;
    }
    private static final com.google.protobuf.Internal.EnumLiteMap<
        DatabaseType> internalValueMap =
          new com.google.protobuf.Internal.EnumLiteMap<DatabaseType>() {
            public DatabaseType findValueByNumber(int number) {
              return DatabaseType.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 com.google.cloud.bigquery.connection.v1.CloudSqlProperties.getDescriptor().getEnumTypes().get(0);
    }

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

    public static DatabaseType 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 DatabaseType(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType)
  }

  public static final int INSTANCE_ID_FIELD_NUMBER = 1;
  private volatile java.lang.Object instanceId_;
  /**
   * <pre>
   * Cloud SQL instance ID in the form `project:location:instance`.
   * </pre>
   *
   * <code>string instance_id = 1;</code>
   * @return The instanceId.
   */
  @java.lang.Override
  public java.lang.String getInstanceId() {
    java.lang.Object ref = instanceId_;
    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();
      instanceId_ = s;
      return s;
    }
  }
  /**
   * <pre>
   * Cloud SQL instance ID in the form `project:location:instance`.
   * </pre>
   *
   * <code>string instance_id = 1;</code>
   * @return The bytes for instanceId.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString
      getInstanceIdBytes() {
    java.lang.Object ref = instanceId_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      instanceId_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int DATABASE_FIELD_NUMBER = 2;
  private volatile java.lang.Object database_;
  /**
   * <pre>
   * Database name.
   * </pre>
   *
   * <code>string database = 2;</code>
   * @return The database.
   */
  @java.lang.Override
  public java.lang.String getDatabase() {
    java.lang.Object ref = database_;
    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();
      database_ = s;
      return s;
    }
  }
  /**
   * <pre>
   * Database name.
   * </pre>
   *
   * <code>string database = 2;</code>
   * @return The bytes for database.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString
      getDatabaseBytes() {
    java.lang.Object ref = database_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      database_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int TYPE_FIELD_NUMBER = 3;
  private int type_;
  /**
   * <pre>
   * Type of the Cloud SQL database.
   * </pre>
   *
   * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
   * @return The enum numeric value on the wire for type.
   */
  @java.lang.Override public int getTypeValue() {
    return type_;
  }
  /**
   * <pre>
   * Type of the Cloud SQL database.
   * </pre>
   *
   * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
   * @return The type.
   */
  @java.lang.Override public com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType getType() {
    @SuppressWarnings("deprecation")
    com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType result = com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.valueOf(type_);
    return result == null ? com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.UNRECOGNIZED : result;
  }

  public static final int CREDENTIAL_FIELD_NUMBER = 4;
  private com.google.cloud.bigquery.connection.v1.CloudSqlCredential credential_;
  /**
   * <pre>
   * Input only. Cloud SQL credential.
   * </pre>
   *
   * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
   * @return Whether the credential field is set.
   */
  @java.lang.Override
  public boolean hasCredential() {
    return credential_ != null;
  }
  /**
   * <pre>
   * Input only. Cloud SQL credential.
   * </pre>
   *
   * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
   * @return The credential.
   */
  @java.lang.Override
  public com.google.cloud.bigquery.connection.v1.CloudSqlCredential getCredential() {
    return credential_ == null ? com.google.cloud.bigquery.connection.v1.CloudSqlCredential.getDefaultInstance() : credential_;
  }
  /**
   * <pre>
   * Input only. Cloud SQL credential.
   * </pre>
   *
   * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
   */
  @java.lang.Override
  public com.google.cloud.bigquery.connection.v1.CloudSqlCredentialOrBuilder getCredentialOrBuilder() {
    return getCredential();
  }

  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(instanceId_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, instanceId_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, database_);
    }
    if (type_ != com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.DATABASE_TYPE_UNSPECIFIED.getNumber()) {
      output.writeEnum(3, type_);
    }
    if (credential_ != null) {
      output.writeMessage(4, getCredential());
    }
    unknownFields.writeTo(output);
  }

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

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(instanceId_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, instanceId_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, database_);
    }
    if (type_ != com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.DATABASE_TYPE_UNSPECIFIED.getNumber()) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(3, type_);
    }
    if (credential_ != null) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(4, getCredential());
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.cloud.bigquery.connection.v1.CloudSqlProperties)) {
      return super.equals(obj);
    }
    com.google.cloud.bigquery.connection.v1.CloudSqlProperties other = (com.google.cloud.bigquery.connection.v1.CloudSqlProperties) obj;

    if (!getInstanceId()
        .equals(other.getInstanceId())) return false;
    if (!getDatabase()
        .equals(other.getDatabase())) return false;
    if (type_ != other.type_) return false;
    if (hasCredential() != other.hasCredential()) return false;
    if (hasCredential()) {
      if (!getCredential()
          .equals(other.getCredential())) 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) + INSTANCE_ID_FIELD_NUMBER;
    hash = (53 * hash) + getInstanceId().hashCode();
    hash = (37 * hash) + DATABASE_FIELD_NUMBER;
    hash = (53 * hash) + getDatabase().hashCode();
    hash = (37 * hash) + TYPE_FIELD_NUMBER;
    hash = (53 * hash) + type_;
    if (hasCredential()) {
      hash = (37 * hash) + CREDENTIAL_FIELD_NUMBER;
      hash = (53 * hash) + getCredential().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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.cloud.bigquery.connection.v1.CloudSqlProperties parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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.cloud.bigquery.connection.v1.CloudSqlProperties parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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.cloud.bigquery.connection.v1.CloudSqlProperties 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>
   * Connection properties specific to the Cloud SQL.
   * </pre>
   *
   * Protobuf type {@code google.cloud.bigquery.connection.v1.CloudSqlProperties}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.cloud.bigquery.connection.v1.CloudSqlProperties)
      com.google.cloud.bigquery.connection.v1.CloudSqlPropertiesOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.cloud.bigquery.connection.v1.ConnectionOuterClass.internal_static_google_cloud_bigquery_connection_v1_CloudSqlProperties_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.bigquery.connection.v1.ConnectionOuterClass.internal_static_google_cloud_bigquery_connection_v1_CloudSqlProperties_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.bigquery.connection.v1.CloudSqlProperties.class, com.google.cloud.bigquery.connection.v1.CloudSqlProperties.Builder.class);
    }

    // Construct using com.google.cloud.bigquery.connection.v1.CloudSqlProperties.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();
      instanceId_ = "";

      database_ = "";

      type_ = 0;

      if (credentialBuilder_ == null) {
        credential_ = null;
      } else {
        credential_ = null;
        credentialBuilder_ = null;
      }
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.cloud.bigquery.connection.v1.ConnectionOuterClass.internal_static_google_cloud_bigquery_connection_v1_CloudSqlProperties_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.bigquery.connection.v1.CloudSqlProperties getDefaultInstanceForType() {
      return com.google.cloud.bigquery.connection.v1.CloudSqlProperties.getDefaultInstance();
    }

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

    @java.lang.Override
    public com.google.cloud.bigquery.connection.v1.CloudSqlProperties buildPartial() {
      com.google.cloud.bigquery.connection.v1.CloudSqlProperties result = new com.google.cloud.bigquery.connection.v1.CloudSqlProperties(this);
      result.instanceId_ = instanceId_;
      result.database_ = database_;
      result.type_ = type_;
      if (credentialBuilder_ == null) {
        result.credential_ = credential_;
      } else {
        result.credential_ = credentialBuilder_.build();
      }
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }
    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.setField(field, value);
    }
    @java.lang.Override
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }
    @java.lang.Override
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }
    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }
    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }
    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.bigquery.connection.v1.CloudSqlProperties) {
        return mergeFrom((com.google.cloud.bigquery.connection.v1.CloudSqlProperties)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.bigquery.connection.v1.CloudSqlProperties other) {
      if (other == com.google.cloud.bigquery.connection.v1.CloudSqlProperties.getDefaultInstance()) return this;
      if (!other.getInstanceId().isEmpty()) {
        instanceId_ = other.instanceId_;
        onChanged();
      }
      if (!other.getDatabase().isEmpty()) {
        database_ = other.database_;
        onChanged();
      }
      if (other.type_ != 0) {
        setTypeValue(other.getTypeValue());
      }
      if (other.hasCredential()) {
        mergeCredential(other.getCredential());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

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

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

    private java.lang.Object instanceId_ = "";
    /**
     * <pre>
     * Cloud SQL instance ID in the form `project:location:instance`.
     * </pre>
     *
     * <code>string instance_id = 1;</code>
     * @return The instanceId.
     */
    public java.lang.String getInstanceId() {
      java.lang.Object ref = instanceId_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        instanceId_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <pre>
     * Cloud SQL instance ID in the form `project:location:instance`.
     * </pre>
     *
     * <code>string instance_id = 1;</code>
     * @return The bytes for instanceId.
     */
    public com.google.protobuf.ByteString
        getInstanceIdBytes() {
      java.lang.Object ref = instanceId_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        instanceId_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <pre>
     * Cloud SQL instance ID in the form `project:location:instance`.
     * </pre>
     *
     * <code>string instance_id = 1;</code>
     * @param value The instanceId to set.
     * @return This builder for chaining.
     */
    public Builder setInstanceId(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }
  
      instanceId_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Cloud SQL instance ID in the form `project:location:instance`.
     * </pre>
     *
     * <code>string instance_id = 1;</code>
     * @return This builder for chaining.
     */
    public Builder clearInstanceId() {
      
      instanceId_ = getDefaultInstance().getInstanceId();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Cloud SQL instance ID in the form `project:location:instance`.
     * </pre>
     *
     * <code>string instance_id = 1;</code>
     * @param value The bytes for instanceId to set.
     * @return This builder for chaining.
     */
    public Builder setInstanceIdBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);
      
      instanceId_ = value;
      onChanged();
      return this;
    }

    private java.lang.Object database_ = "";
    /**
     * <pre>
     * Database name.
     * </pre>
     *
     * <code>string database = 2;</code>
     * @return The database.
     */
    public java.lang.String getDatabase() {
      java.lang.Object ref = database_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        database_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     * <pre>
     * Database name.
     * </pre>
     *
     * <code>string database = 2;</code>
     * @return The bytes for database.
     */
    public com.google.protobuf.ByteString
        getDatabaseBytes() {
      java.lang.Object ref = database_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b = 
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        database_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     * <pre>
     * Database name.
     * </pre>
     *
     * <code>string database = 2;</code>
     * @param value The database to set.
     * @return This builder for chaining.
     */
    public Builder setDatabase(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }
  
      database_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Database name.
     * </pre>
     *
     * <code>string database = 2;</code>
     * @return This builder for chaining.
     */
    public Builder clearDatabase() {
      
      database_ = getDefaultInstance().getDatabase();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Database name.
     * </pre>
     *
     * <code>string database = 2;</code>
     * @param value The bytes for database to set.
     * @return This builder for chaining.
     */
    public Builder setDatabaseBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);
      
      database_ = value;
      onChanged();
      return this;
    }

    private int type_ = 0;
    /**
     * <pre>
     * Type of the Cloud SQL database.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
     * @return The enum numeric value on the wire for type.
     */
    @java.lang.Override public int getTypeValue() {
      return type_;
    }
    /**
     * <pre>
     * Type of the Cloud SQL database.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
     * @param value The enum numeric value on the wire for type to set.
     * @return This builder for chaining.
     */
    public Builder setTypeValue(int value) {
      
      type_ = value;
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Type of the Cloud SQL database.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
     * @return The type.
     */
    @java.lang.Override
    public com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType getType() {
      @SuppressWarnings("deprecation")
      com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType result = com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.valueOf(type_);
      return result == null ? com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType.UNRECOGNIZED : result;
    }
    /**
     * <pre>
     * Type of the Cloud SQL database.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
     * @param value The type to set.
     * @return This builder for chaining.
     */
    public Builder setType(com.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType value) {
      if (value == null) {
        throw new NullPointerException();
      }
      
      type_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     * <pre>
     * Type of the Cloud SQL database.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlProperties.DatabaseType type = 3;</code>
     * @return This builder for chaining.
     */
    public Builder clearType() {
      
      type_ = 0;
      onChanged();
      return this;
    }

    private com.google.cloud.bigquery.connection.v1.CloudSqlCredential credential_;
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.cloud.bigquery.connection.v1.CloudSqlCredential, com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder, com.google.cloud.bigquery.connection.v1.CloudSqlCredentialOrBuilder> credentialBuilder_;
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     * @return Whether the credential field is set.
     */
    public boolean hasCredential() {
      return credentialBuilder_ != null || credential_ != null;
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     * @return The credential.
     */
    public com.google.cloud.bigquery.connection.v1.CloudSqlCredential getCredential() {
      if (credentialBuilder_ == null) {
        return credential_ == null ? com.google.cloud.bigquery.connection.v1.CloudSqlCredential.getDefaultInstance() : credential_;
      } else {
        return credentialBuilder_.getMessage();
      }
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public Builder setCredential(com.google.cloud.bigquery.connection.v1.CloudSqlCredential value) {
      if (credentialBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        credential_ = value;
        onChanged();
      } else {
        credentialBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public Builder setCredential(
        com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder builderForValue) {
      if (credentialBuilder_ == null) {
        credential_ = builderForValue.build();
        onChanged();
      } else {
        credentialBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public Builder mergeCredential(com.google.cloud.bigquery.connection.v1.CloudSqlCredential value) {
      if (credentialBuilder_ == null) {
        if (credential_ != null) {
          credential_ =
            com.google.cloud.bigquery.connection.v1.CloudSqlCredential.newBuilder(credential_).mergeFrom(value).buildPartial();
        } else {
          credential_ = value;
        }
        onChanged();
      } else {
        credentialBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public Builder clearCredential() {
      if (credentialBuilder_ == null) {
        credential_ = null;
        onChanged();
      } else {
        credential_ = null;
        credentialBuilder_ = null;
      }

      return this;
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder getCredentialBuilder() {
      
      onChanged();
      return getCredentialFieldBuilder().getBuilder();
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    public com.google.cloud.bigquery.connection.v1.CloudSqlCredentialOrBuilder getCredentialOrBuilder() {
      if (credentialBuilder_ != null) {
        return credentialBuilder_.getMessageOrBuilder();
      } else {
        return credential_ == null ?
            com.google.cloud.bigquery.connection.v1.CloudSqlCredential.getDefaultInstance() : credential_;
      }
    }
    /**
     * <pre>
     * Input only. Cloud SQL credential.
     * </pre>
     *
     * <code>.google.cloud.bigquery.connection.v1.CloudSqlCredential credential = 4 [(.google.api.field_behavior) = INPUT_ONLY];</code>
     */
    private com.google.protobuf.SingleFieldBuilderV3<
        com.google.cloud.bigquery.connection.v1.CloudSqlCredential, com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder, com.google.cloud.bigquery.connection.v1.CloudSqlCredentialOrBuilder> 
        getCredentialFieldBuilder() {
      if (credentialBuilder_ == null) {
        credentialBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
            com.google.cloud.bigquery.connection.v1.CloudSqlCredential, com.google.cloud.bigquery.connection.v1.CloudSqlCredential.Builder, com.google.cloud.bigquery.connection.v1.CloudSqlCredentialOrBuilder>(
                getCredential(),
                getParentForChildren(),
                isClean());
        credential_ = null;
      }
      return credentialBuilder_;
    }
    @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.cloud.bigquery.connection.v1.CloudSqlProperties)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.bigquery.connection.v1.CloudSqlProperties)
  private static final com.google.cloud.bigquery.connection.v1.CloudSqlProperties DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.cloud.bigquery.connection.v1.CloudSqlProperties();
  }

  public static com.google.cloud.bigquery.connection.v1.CloudSqlProperties getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

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

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

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

  @java.lang.Override
  public com.google.cloud.bigquery.connection.v1.CloudSqlProperties getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

