TGcpCredential.java

/**
 * Autogenerated by Thrift Compiler (0.24.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.doris.thrift;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
public class TGcpCredential implements org.apache.thrift.TBase<TGcpCredential, TGcpCredential._Fields>, java.io.Serializable, Cloneable, Comparable<TGcpCredential> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGcpCredential");

  private static final org.apache.thrift.protocol.TField CREDENTIAL_PROVIDER_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("credential_provider_type", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField IMPERSONATION_SERVICE_ACCOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("impersonation_service_account", org.apache.thrift.protocol.TType.STRING, (short)2);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TGcpCredentialStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TGcpCredentialTupleSchemeFactory();

  /**
   * 
   * @see TGcpCredentialProviderType
   */
  public @org.apache.thrift.annotation.Nullable TGcpCredentialProviderType credential_provider_type; // optional
  public @org.apache.thrift.annotation.Nullable java.lang.String impersonation_service_account; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    /**
     * 
     * @see TGcpCredentialProviderType
     */
    CREDENTIAL_PROVIDER_TYPE((short)1, "credential_provider_type"),
    IMPERSONATION_SERVICE_ACCOUNT((short)2, "impersonation_service_account");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // CREDENTIAL_PROVIDER_TYPE
          return CREDENTIAL_PROVIDER_TYPE;
        case 2: // IMPERSONATION_SERVICE_ACCOUNT
          return IMPERSONATION_SERVICE_ACCOUNT;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    @Override
    public short getThriftFieldId() {
      return _thriftId;
    }

    @Override
    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final _Fields[] optionals = {_Fields.CREDENTIAL_PROVIDER_TYPE,_Fields.IMPERSONATION_SERVICE_ACCOUNT};
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.CREDENTIAL_PROVIDER_TYPE, new org.apache.thrift.meta_data.FieldMetaData("credential_provider_type", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TGcpCredentialProviderType.class)));
    tmpMap.put(_Fields.IMPERSONATION_SERVICE_ACCOUNT, new org.apache.thrift.meta_data.FieldMetaData("impersonation_service_account", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGcpCredential.class, metaDataMap);
  }

  public TGcpCredential() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TGcpCredential(TGcpCredential other) {
    if (other.isSetCredentialProviderType()) {
      this.credential_provider_type = other.credential_provider_type;
    }
    if (other.isSetImpersonationServiceAccount()) {
      this.impersonation_service_account = other.impersonation_service_account;
    }
  }

  @Override
  public TGcpCredential deepCopy() {
    return new TGcpCredential(this);
  }

  @Override
  public void clear() {
    this.credential_provider_type = null;
    this.impersonation_service_account = null;
  }

  /**
   * 
   * @see TGcpCredentialProviderType
   */
  @org.apache.thrift.annotation.Nullable
  public TGcpCredentialProviderType getCredentialProviderType() {
    return this.credential_provider_type;
  }

  /**
   * 
   * @see TGcpCredentialProviderType
   */
  public TGcpCredential setCredentialProviderType(@org.apache.thrift.annotation.Nullable TGcpCredentialProviderType credential_provider_type) {
    this.credential_provider_type = credential_provider_type;
    return this;
  }

  public void unsetCredentialProviderType() {
    this.credential_provider_type = null;
  }

  /** Returns true if field credential_provider_type is set (has been assigned a value) and false otherwise */
  public boolean isSetCredentialProviderType() {
    return this.credential_provider_type != null;
  }

  public void setCredentialProviderTypeIsSet(boolean value) {
    if (!value) {
      this.credential_provider_type = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getImpersonationServiceAccount() {
    return this.impersonation_service_account;
  }

  public TGcpCredential setImpersonationServiceAccount(@org.apache.thrift.annotation.Nullable java.lang.String impersonation_service_account) {
    this.impersonation_service_account = impersonation_service_account;
    return this;
  }

  public void unsetImpersonationServiceAccount() {
    this.impersonation_service_account = null;
  }

  /** Returns true if field impersonation_service_account is set (has been assigned a value) and false otherwise */
  public boolean isSetImpersonationServiceAccount() {
    return this.impersonation_service_account != null;
  }

  public void setImpersonationServiceAccountIsSet(boolean value) {
    if (!value) {
      this.impersonation_service_account = null;
    }
  }

  @Override
  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case CREDENTIAL_PROVIDER_TYPE:
      if (value == null) {
        unsetCredentialProviderType();
      } else {
        setCredentialProviderType((TGcpCredentialProviderType)value);
      }
      break;

    case IMPERSONATION_SERVICE_ACCOUNT:
      if (value == null) {
        unsetImpersonationServiceAccount();
      } else {
        setImpersonationServiceAccount((java.lang.String)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  @Override
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case CREDENTIAL_PROVIDER_TYPE:
      return getCredentialProviderType();

    case IMPERSONATION_SERVICE_ACCOUNT:
      return getImpersonationServiceAccount();

    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  @Override
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case CREDENTIAL_PROVIDER_TYPE:
      return isSetCredentialProviderType();
    case IMPERSONATION_SERVICE_ACCOUNT:
      return isSetImpersonationServiceAccount();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof TGcpCredential)
      return this.equals((TGcpCredential)that);
    return false;
  }

  public boolean equals(TGcpCredential that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_credential_provider_type = true && this.isSetCredentialProviderType();
    boolean that_present_credential_provider_type = true && that.isSetCredentialProviderType();
    if (this_present_credential_provider_type || that_present_credential_provider_type) {
      if (!(this_present_credential_provider_type && that_present_credential_provider_type))
        return false;
      if (!this.credential_provider_type.equals(that.credential_provider_type))
        return false;
    }

    boolean this_present_impersonation_service_account = true && this.isSetImpersonationServiceAccount();
    boolean that_present_impersonation_service_account = true && that.isSetImpersonationServiceAccount();
    if (this_present_impersonation_service_account || that_present_impersonation_service_account) {
      if (!(this_present_impersonation_service_account && that_present_impersonation_service_account))
        return false;
      if (!this.impersonation_service_account.equals(that.impersonation_service_account))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetCredentialProviderType()) ? 131071 : 524287);
    if (isSetCredentialProviderType())
      hashCode = hashCode * 8191 + credential_provider_type.getValue();

    hashCode = hashCode * 8191 + ((isSetImpersonationServiceAccount()) ? 131071 : 524287);
    if (isSetImpersonationServiceAccount())
      hashCode = hashCode * 8191 + impersonation_service_account.hashCode();

    return hashCode;
  }

  @Override
  public int compareTo(TGcpCredential other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetCredentialProviderType(), other.isSetCredentialProviderType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCredentialProviderType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credential_provider_type, other.credential_provider_type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetImpersonationServiceAccount(), other.isSetImpersonationServiceAccount());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetImpersonationServiceAccount()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.impersonation_service_account, other.impersonation_service_account);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  @Override
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  @Override
  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  @Override
  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("TGcpCredential(");
    boolean first = true;

    if (isSetCredentialProviderType()) {
      sb.append("credential_provider_type:");
      if (this.credential_provider_type == null) {
        sb.append("null");
      } else {
        sb.append(this.credential_provider_type);
      }
      first = false;
    }
    if (isSetImpersonationServiceAccount()) {
      if (!first) sb.append(", ");
      sb.append("impersonation_service_account:");
      if (this.impersonation_service_account == null) {
        sb.append("null");
      } else {
        sb.append(this.impersonation_service_account);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class TGcpCredentialStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    @Override
    public TGcpCredentialStandardScheme getScheme() {
      return new TGcpCredentialStandardScheme();
    }
  }

  private static class TGcpCredentialStandardScheme extends org.apache.thrift.scheme.StandardScheme<TGcpCredential> {

    @Override
    public void read(org.apache.thrift.protocol.TProtocol iprot, TGcpCredential struct) throws org.apache.thrift.TException {
      iprot.incrementRecursionDepth();
      try {
        org.apache.thrift.protocol.TField schemeField;
        iprot.readStructBegin();
        while (true)
        {
          schemeField = iprot.readFieldBegin();
          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
            break;
          }
          switch (schemeField.id) {
            case 1: // CREDENTIAL_PROVIDER_TYPE
              if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                struct.credential_provider_type = org.apache.doris.thrift.TGcpCredentialProviderType.findByValue(iprot.readI32());
                struct.setCredentialProviderTypeIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 2: // IMPERSONATION_SERVICE_ACCOUNT
              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                struct.impersonation_service_account = iprot.readString();
                struct.setImpersonationServiceAccountIsSet(true);
              } else { 
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            default:
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
          }
          iprot.readFieldEnd();
        }
        iprot.readStructEnd();

        // check for required fields of primitive type, which can't be checked in the validate method
        struct.validate();
      } finally {
        iprot.decrementRecursionDepth();
      }
    }

    @Override
    public void write(org.apache.thrift.protocol.TProtocol oprot, TGcpCredential struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.credential_provider_type != null) {
        if (struct.isSetCredentialProviderType()) {
          oprot.writeFieldBegin(CREDENTIAL_PROVIDER_TYPE_FIELD_DESC);
          oprot.writeI32(struct.credential_provider_type.getValue());
          oprot.writeFieldEnd();
        }
      }
      if (struct.impersonation_service_account != null) {
        if (struct.isSetImpersonationServiceAccount()) {
          oprot.writeFieldBegin(IMPERSONATION_SERVICE_ACCOUNT_FIELD_DESC);
          oprot.writeString(struct.impersonation_service_account);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class TGcpCredentialTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    @Override
    public TGcpCredentialTupleScheme getScheme() {
      return new TGcpCredentialTupleScheme();
    }
  }

  private static class TGcpCredentialTupleScheme extends org.apache.thrift.scheme.TupleScheme<TGcpCredential> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TGcpCredential struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetCredentialProviderType()) {
        optionals.set(0);
      }
      if (struct.isSetImpersonationServiceAccount()) {
        optionals.set(1);
      }
      oprot.writeBitSet(optionals, 2);
      if (struct.isSetCredentialProviderType()) {
        oprot.writeI32(struct.credential_provider_type.getValue());
      }
      if (struct.isSetImpersonationServiceAccount()) {
        oprot.writeString(struct.impersonation_service_account);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TGcpCredential struct) throws org.apache.thrift.TException {
      prot.incrementRecursionDepth();
      try {
        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
        java.util.BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          struct.credential_provider_type = org.apache.doris.thrift.TGcpCredentialProviderType.findByValue(iprot.readI32());
          struct.setCredentialProviderTypeIsSet(true);
        }
        if (incoming.get(1)) {
          struct.impersonation_service_account = iprot.readString();
          struct.setImpersonationServiceAccountIsSet(true);
        }
      } finally {
        prot.decrementRecursionDepth();
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}