/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.facebook.thrift.annotation.cpp_deprecated;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import com.facebook.thrift.*;
import com.facebook.thrift.annotations.*;
import com.facebook.thrift.async.*;
import com.facebook.thrift.meta_data.*;
import com.facebook.thrift.server.*;
import com.facebook.thrift.transport.*;
import com.facebook.thrift.protocol.*;

/**
 * An annotation that applies a C++ adapter to typedef, field, or struct.
 * 
 * For example:
 * 
 *   @cpp.Adapter{name = "::ns::IdAdapter"}
 *   typedef i64 MyI64;
 * 
 * Here the type `MyI64` has the C++ adapter `IdAdapter`.
 * 
 *   struct User {
 *     @cpp.Adapter{name = "::ns::IdAdapter"}
 *     1: i64 id;
 *   }
 * 
 * Here the field `id` has the C++ adapter `IdAdapter`.
 */
@SuppressWarnings({ "unused", "serial" })
public class Adapter implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("Adapter");
  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
  private static final TField ADAPTED_TYPE_FIELD_DESC = new TField("adaptedType", TType.STRING, (short)2);
  private static final TField UNDERLYING_NAME_FIELD_DESC = new TField("underlyingName", TType.STRING, (short)3);
  private static final TField EXTRA_NAMESPACE_FIELD_DESC = new TField("extraNamespace", TType.STRING, (short)4);
  private static final TField MOVE_ONLY_FIELD_DESC = new TField("moveOnly", TType.BOOL, (short)5);

  /**
   * The name of a C++ adapter type used to convert between Thrift and native
   * C++ representation.
   * 
   * The adapter can be either a Type or Field adapter, providing either of the following APIs:
   * 
   *     struct ThriftTypeAdapter {
   *       static AdaptedType fromThrift(ThriftType thrift);
   *       static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native);
   *     };
   * 
   *     struct ThriftFieldAdapter {
   *       // Context is an instantiation of apache::thrift::FieldContext
   *       template <class Context>
   *       static void construct(AdaptedType& field, Context ctx);
   * 
   *       template <class Context>
   *       static AdaptedType fromThriftField(ThriftType value, Context ctx);
   * 
   *       template <class Context>
   *       static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx);
   *     };
   */
  public final String name;
  /**
   * It is sometimes necessary to specify AdaptedType here (in case the codegen would
   * have a circular depdenceny, which will cause the C++ build to fail).
   */
  public final String adaptedType;
  /**
   * The name and/or extra namespace to use when directly adapting a type
   * (as opposed a typedef).
   * 
   * In this case, the IDL name of the type will refer to the adapted type in
   * C++ and the underlying thrift type will be generated in a nested
   * namespace and/or with a different name.
   * 
   * If neither `underlyingName` or `extraNamespace` is provided, the
   * underlying type will be generated in a nested 'detail' namespace with
   * the same name.
   */
  public final String underlyingName;
  public final String extraNamespace;
  /**
   * Must set to true when adapted type is not copyable.
   */
  public final Boolean moveOnly;
  public static final int NAME = 1;
  public static final int ADAPTEDTYPE = 2;
  public static final int UNDERLYINGNAME = 3;
  public static final int EXTRANAMESPACE = 4;
  public static final int MOVEONLY = 5;

  public Adapter(
      String name,
      String adaptedType,
      String underlyingName,
      String extraNamespace,
      Boolean moveOnly) {
    this.name = name;
    this.adaptedType = adaptedType;
    this.underlyingName = underlyingName;
    this.extraNamespace = extraNamespace;
    this.moveOnly = moveOnly;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Adapter(Adapter other) {
    if (other.isSetName()) {
      this.name = TBaseHelper.deepCopy(other.name);
    } else {
      this.name = null;
    }
    if (other.isSetAdaptedType()) {
      this.adaptedType = TBaseHelper.deepCopy(other.adaptedType);
    } else {
      this.adaptedType = null;
    }
    if (other.isSetUnderlyingName()) {
      this.underlyingName = TBaseHelper.deepCopy(other.underlyingName);
    } else {
      this.underlyingName = null;
    }
    if (other.isSetExtraNamespace()) {
      this.extraNamespace = TBaseHelper.deepCopy(other.extraNamespace);
    } else {
      this.extraNamespace = null;
    }
    if (other.isSetMoveOnly()) {
      this.moveOnly = TBaseHelper.deepCopy(other.moveOnly);
    } else {
      this.moveOnly = null;
    }
  }

  public Adapter deepCopy() {
    return new Adapter(this);
  }

  /**
   * The name of a C++ adapter type used to convert between Thrift and native
   * C++ representation.
   * 
   * The adapter can be either a Type or Field adapter, providing either of the following APIs:
   * 
   *     struct ThriftTypeAdapter {
   *       static AdaptedType fromThrift(ThriftType thrift);
   *       static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native);
   *     };
   * 
   *     struct ThriftFieldAdapter {
   *       // Context is an instantiation of apache::thrift::FieldContext
   *       template <class Context>
   *       static void construct(AdaptedType& field, Context ctx);
   * 
   *       template <class Context>
   *       static AdaptedType fromThriftField(ThriftType value, Context ctx);
   * 
   *       template <class Context>
   *       static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx);
   *     };
   */
  public String getName() {
    return this.name;
  }

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

  /**
   * It is sometimes necessary to specify AdaptedType here (in case the codegen would
   * have a circular depdenceny, which will cause the C++ build to fail).
   */
  public String getAdaptedType() {
    return this.adaptedType;
  }

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

  /**
   * The name and/or extra namespace to use when directly adapting a type
   * (as opposed a typedef).
   * 
   * In this case, the IDL name of the type will refer to the adapted type in
   * C++ and the underlying thrift type will be generated in a nested
   * namespace and/or with a different name.
   * 
   * If neither `underlyingName` or `extraNamespace` is provided, the
   * underlying type will be generated in a nested 'detail' namespace with
   * the same name.
   */
  public String getUnderlyingName() {
    return this.underlyingName;
  }

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

  public String getExtraNamespace() {
    return this.extraNamespace;
  }

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

  /**
   * Must set to true when adapted type is not copyable.
   */
  public Boolean isMoveOnly() {
    return this.moveOnly;
  }

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

  @Override
  public boolean equals(Object _that) {
    if (_that == null)
      return false;
    if (this == _that)
      return true;
    if (!(_that instanceof Adapter))
      return false;
    Adapter that = (Adapter)_that;

    if (!TBaseHelper.equalsNobinary(this.isSetName(), that.isSetName(), this.name, that.name)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetAdaptedType(), that.isSetAdaptedType(), this.adaptedType, that.adaptedType)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetUnderlyingName(), that.isSetUnderlyingName(), this.underlyingName, that.underlyingName)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetExtraNamespace(), that.isSetExtraNamespace(), this.extraNamespace, that.extraNamespace)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMoveOnly(), that.isSetMoveOnly(), this.moveOnly, that.moveOnly)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {name, adaptedType, underlyingName, extraNamespace, moveOnly});
  }

  // This is required to satisfy the TBase interface, but can't be implemented on immutable struture.
  public void read(TProtocol iprot) throws TException {
    throw new TException("unimplemented in android immutable structure");
  }

  public static Adapter deserialize(TProtocol iprot) throws TException {
    String tmp_name = null;
    String tmp_adaptedType = null;
    String tmp_underlyingName = null;
    String tmp_extraNamespace = null;
    Boolean tmp_moveOnly = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case NAME:
          if (__field.type == TType.STRING) {
            tmp_name = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ADAPTEDTYPE:
          if (__field.type == TType.STRING) {
            tmp_adaptedType = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case UNDERLYINGNAME:
          if (__field.type == TType.STRING) {
            tmp_underlyingName = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case EXTRANAMESPACE:
          if (__field.type == TType.STRING) {
            tmp_extraNamespace = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MOVEONLY:
          if (__field.type == TType.BOOL) {
            tmp_moveOnly = iprot.readBool();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    Adapter _that;
    _that = new Adapter(
      tmp_name
      ,tmp_adaptedType
      ,tmp_underlyingName
      ,tmp_extraNamespace
      ,tmp_moveOnly
    );
    _that.validate();
    return _that;
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.name != null) {
      oprot.writeFieldBegin(NAME_FIELD_DESC);
      oprot.writeString(this.name);
      oprot.writeFieldEnd();
    }
    if (this.adaptedType != null) {
      oprot.writeFieldBegin(ADAPTED_TYPE_FIELD_DESC);
      oprot.writeString(this.adaptedType);
      oprot.writeFieldEnd();
    }
    if (this.underlyingName != null) {
      oprot.writeFieldBegin(UNDERLYING_NAME_FIELD_DESC);
      oprot.writeString(this.underlyingName);
      oprot.writeFieldEnd();
    }
    if (this.extraNamespace != null) {
      oprot.writeFieldBegin(EXTRA_NAMESPACE_FIELD_DESC);
      oprot.writeString(this.extraNamespace);
      oprot.writeFieldEnd();
    }
    if (this.moveOnly != null) {
      oprot.writeFieldBegin(MOVE_ONLY_FIELD_DESC);
      oprot.writeBool(this.moveOnly);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    return toString(1, true);
  }

  @Override
  public String toString(int indent, boolean prettyPrint) {
    return TBaseHelper.toStringHelper(this, indent, prettyPrint);
  }

  public void validate() throws TException {
    // check for required fields
  }

}

