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

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 MyStruct implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("MyStruct");
  private static final TField ME2_3_FIELD_DESC = new TField("me2_3", TType.I32, (short)1);
  private static final TField ME3_N3_FIELD_DESC = new TField("me3_n3", TType.I32, (short)2);
  private static final TField ME1_T1_FIELD_DESC = new TField("me1_t1", TType.I32, (short)4);
  private static final TField ME1_T2_FIELD_DESC = new TField("me1_t2", TType.I32, (short)6);

  /**
   * 
   * @see MyEnum2
   */
  public final MyEnum2 me2_3;
  /**
   * 
   * @see MyEnum3
   */
  public final MyEnum3 me3_n3;
  /**
   * 
   * @see MyEnum1
   */
  public final MyEnum1 me1_t1;
  /**
   * 
   * @see MyEnum1
   */
  public final MyEnum1 me1_t2;
  public static final int ME2_3 = 1;
  public static final int ME3_N3 = 2;
  public static final int ME1_T1 = 4;
  public static final int ME1_T2 = 6;

  public MyStruct(
      MyEnum2 me2_3,
      MyEnum3 me3_n3,
      MyEnum1 me1_t1,
      MyEnum1 me1_t2) {
    this.me2_3 = me2_3;
    this.me3_n3 = me3_n3;
    this.me1_t1 = me1_t1;
    this.me1_t2 = me1_t2;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MyStruct(MyStruct other) {
    if (other.isSetMe2_3()) {
      this.me2_3 = TBaseHelper.deepCopy(other.me2_3);
    } else {
      this.me2_3 = null;
    }
    if (other.isSetMe3_n3()) {
      this.me3_n3 = TBaseHelper.deepCopy(other.me3_n3);
    } else {
      this.me3_n3 = null;
    }
    if (other.isSetMe1_t1()) {
      this.me1_t1 = TBaseHelper.deepCopy(other.me1_t1);
    } else {
      this.me1_t1 = null;
    }
    if (other.isSetMe1_t2()) {
      this.me1_t2 = TBaseHelper.deepCopy(other.me1_t2);
    } else {
      this.me1_t2 = null;
    }
  }

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

  /**
   * 
   * @see MyEnum2
   */
  public MyEnum2 getMe2_3() {
    return this.me2_3;
  }

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

  /**
   * 
   * @see MyEnum3
   */
  public MyEnum3 getMe3_n3() {
    return this.me3_n3;
  }

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

  /**
   * 
   * @see MyEnum1
   */
  public MyEnum1 getMe1_t1() {
    return this.me1_t1;
  }

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

  /**
   * 
   * @see MyEnum1
   */
  public MyEnum1 getMe1_t2() {
    return this.me1_t2;
  }

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

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

    if (!TBaseHelper.equalsNobinary(this.isSetMe2_3(), that.isSetMe2_3(), this.me2_3, that.me2_3)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMe3_n3(), that.isSetMe3_n3(), this.me3_n3, that.me3_n3)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMe1_t1(), that.isSetMe1_t1(), this.me1_t1, that.me1_t1)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMe1_t2(), that.isSetMe1_t2(), this.me1_t2, that.me1_t2)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {me2_3, me3_n3, me1_t1, me1_t2});
  }

  // 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 MyStruct deserialize(TProtocol iprot) throws TException {
    MyEnum2 tmp_me2_3 = null;
    MyEnum3 tmp_me3_n3 = null;
    MyEnum1 tmp_me1_t1 = null;
    MyEnum1 tmp_me1_t2 = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case ME2_3:
          if (__field.type == TType.I32) {
            tmp_me2_3 = MyEnum2.findByValue(iprot.readI32());
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ME3_N3:
          if (__field.type == TType.I32) {
            tmp_me3_n3 = MyEnum3.findByValue(iprot.readI32());
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ME1_T1:
          if (__field.type == TType.I32) {
            tmp_me1_t1 = MyEnum1.findByValue(iprot.readI32());
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ME1_T2:
          if (__field.type == TType.I32) {
            tmp_me1_t2 = MyEnum1.findByValue(iprot.readI32());
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    MyStruct _that;
    _that = new MyStruct(
      tmp_me2_3
      ,tmp_me3_n3
      ,tmp_me1_t1
      ,tmp_me1_t2
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.me2_3 != null) {
      oprot.writeFieldBegin(ME2_3_FIELD_DESC);
      oprot.writeI32(this.me2_3 == null ? 0 : this.me2_3.getValue());
      oprot.writeFieldEnd();
    }
    if (this.me3_n3 != null) {
      oprot.writeFieldBegin(ME3_N3_FIELD_DESC);
      oprot.writeI32(this.me3_n3 == null ? 0 : this.me3_n3.getValue());
      oprot.writeFieldEnd();
    }
    if (this.me1_t1 != null) {
      oprot.writeFieldBegin(ME1_T1_FIELD_DESC);
      oprot.writeI32(this.me1_t1 == null ? 0 : this.me1_t1.getValue());
      oprot.writeFieldEnd();
    }
    if (this.me1_t2 != null) {
      oprot.writeFieldBegin(ME1_T2_FIELD_DESC);
      oprot.writeI32(this.me1_t2 == null ? 0 : this.me1_t2.getValue());
      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
  }

}

