/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package test.fixtures.adapter;

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.*;

@SuppressWarnings({ "unused", "serial" })
public class StructFieldAdaptedStruct implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("StructFieldAdaptedStruct");
  private static final TField ADAPTED_STRUCT_FIELD_DESC = new TField("adaptedStruct", TType.STRUCT, (short)1);
  private static final TField ADAPTED_TYPEDEF_FIELD_DESC = new TField("adaptedTypedef", TType.STRUCT, (short)2);
  private static final TField DIRECTLY_ADAPTED_FIELD_DESC = new TField("directlyAdapted", TType.STRUCT, (short)3);
  private static final TField TYPEDEF_OF_ADAPTED_FIELD_DESC = new TField("typedefOfAdapted", TType.STRUCT, (short)4);

  public final AdaptedStruct adaptedStruct;
  public final AdaptedStruct adaptedTypedef;
  public final DirectlyAdaptedStruct directlyAdapted;
  public final DirectlyAdaptedStruct typedefOfAdapted;
  public static final int ADAPTEDSTRUCT = 1;
  public static final int ADAPTEDTYPEDEF = 2;
  public static final int DIRECTLYADAPTED = 3;
  public static final int TYPEDEFOFADAPTED = 4;

  public StructFieldAdaptedStruct(
      AdaptedStruct adaptedStruct,
      AdaptedStruct adaptedTypedef,
      DirectlyAdaptedStruct directlyAdapted,
      DirectlyAdaptedStruct typedefOfAdapted) {
    this.adaptedStruct = adaptedStruct;
    this.adaptedTypedef = adaptedTypedef;
    this.directlyAdapted = directlyAdapted;
    this.typedefOfAdapted = typedefOfAdapted;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public StructFieldAdaptedStruct(StructFieldAdaptedStruct other) {
    if (other.isSetAdaptedStruct()) {
      this.adaptedStruct = TBaseHelper.deepCopy(other.adaptedStruct);
    } else {
      this.adaptedStruct = null;
    }
    if (other.isSetAdaptedTypedef()) {
      this.adaptedTypedef = TBaseHelper.deepCopy(other.adaptedTypedef);
    } else {
      this.adaptedTypedef = null;
    }
    if (other.isSetDirectlyAdapted()) {
      this.directlyAdapted = TBaseHelper.deepCopy(other.directlyAdapted);
    } else {
      this.directlyAdapted = null;
    }
    if (other.isSetTypedefOfAdapted()) {
      this.typedefOfAdapted = TBaseHelper.deepCopy(other.typedefOfAdapted);
    } else {
      this.typedefOfAdapted = null;
    }
  }

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

  public AdaptedStruct getAdaptedStruct() {
    return this.adaptedStruct;
  }

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

  public AdaptedStruct getAdaptedTypedef() {
    return this.adaptedTypedef;
  }

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

  public DirectlyAdaptedStruct getDirectlyAdapted() {
    return this.directlyAdapted;
  }

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

  public DirectlyAdaptedStruct getTypedefOfAdapted() {
    return this.typedefOfAdapted;
  }

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

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

    if (!TBaseHelper.equalsNobinary(this.isSetAdaptedStruct(), that.isSetAdaptedStruct(), this.adaptedStruct, that.adaptedStruct)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetAdaptedTypedef(), that.isSetAdaptedTypedef(), this.adaptedTypedef, that.adaptedTypedef)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetDirectlyAdapted(), that.isSetDirectlyAdapted(), this.directlyAdapted, that.directlyAdapted)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetTypedefOfAdapted(), that.isSetTypedefOfAdapted(), this.typedefOfAdapted, that.typedefOfAdapted)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {adaptedStruct, adaptedTypedef, directlyAdapted, typedefOfAdapted});
  }

  // 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 StructFieldAdaptedStruct deserialize(TProtocol iprot) throws TException {
    AdaptedStruct tmp_adaptedStruct = null;
    AdaptedStruct tmp_adaptedTypedef = null;
    DirectlyAdaptedStruct tmp_directlyAdapted = null;
    DirectlyAdaptedStruct tmp_typedefOfAdapted = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case ADAPTEDSTRUCT:
          if (__field.type == TType.STRUCT) {
            tmp_adaptedStruct = AdaptedStruct.deserialize(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ADAPTEDTYPEDEF:
          if (__field.type == TType.STRUCT) {
            tmp_adaptedTypedef = AdaptedStruct.deserialize(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case DIRECTLYADAPTED:
          if (__field.type == TType.STRUCT) {
            tmp_directlyAdapted = DirectlyAdaptedStruct.deserialize(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case TYPEDEFOFADAPTED:
          if (__field.type == TType.STRUCT) {
            tmp_typedefOfAdapted = DirectlyAdaptedStruct.deserialize(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    StructFieldAdaptedStruct _that;
    _that = new StructFieldAdaptedStruct(
      tmp_adaptedStruct
      ,tmp_adaptedTypedef
      ,tmp_directlyAdapted
      ,tmp_typedefOfAdapted
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.adaptedStruct != null) {
      oprot.writeFieldBegin(ADAPTED_STRUCT_FIELD_DESC);
      this.adaptedStruct.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.adaptedTypedef != null) {
      oprot.writeFieldBegin(ADAPTED_TYPEDEF_FIELD_DESC);
      this.adaptedTypedef.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.directlyAdapted != null) {
      oprot.writeFieldBegin(DIRECTLY_ADAPTED_FIELD_DESC);
      this.directlyAdapted.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.typedefOfAdapted != null) {
      oprot.writeFieldBegin(TYPEDEF_OF_ADAPTED_FIELD_DESC);
      this.typedefOfAdapted.write(oprot);
      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
  }

}

