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

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 MyExceptionWithMessage extends Exception implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("MyExceptionWithMessage");
  private static final TField MY_INT_FIELD_FIELD_DESC = new TField("MyIntField", TType.I64, (short)1);
  private static final TField MY_STRING_FIELD_FIELD_DESC = new TField("MyStringField", TType.STRING, (short)2);
  private static final TField MY_STRUCT_FIELD_DESC = new TField("myStruct", TType.STRUCT, (short)3);
  private static final TField MY_UNION_FIELD_DESC = new TField("myUnion", TType.STRUCT, (short)4);

  public final Long MyIntField;
  public final String MyStringField;
  public final MyStruct myStruct;
  public final MyUnion myUnion;
  public static final int MYINTFIELD = 1;
  public static final int MYSTRINGFIELD = 2;
  public static final int MYSTRUCT = 3;
  public static final int MYUNION = 4;

  public MyExceptionWithMessage(
      Long MyIntField,
      String MyStringField,
      MyStruct myStruct,
      MyUnion myUnion) {
    this.MyIntField = MyIntField;
    this.MyStringField = MyStringField;
    this.myStruct = myStruct;
    this.myUnion = myUnion;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MyExceptionWithMessage(MyExceptionWithMessage other) {
    if (other.isSetMyIntField()) {
      this.MyIntField = TBaseHelper.deepCopy(other.MyIntField);
    } else {
      this.MyIntField = null;
    }
    if (other.isSetMyStringField()) {
      this.MyStringField = TBaseHelper.deepCopy(other.MyStringField);
    } else {
      this.MyStringField = null;
    }
    if (other.isSetMyStruct()) {
      this.myStruct = TBaseHelper.deepCopy(other.myStruct);
    } else {
      this.myStruct = null;
    }
    if (other.isSetMyUnion()) {
      this.myUnion = TBaseHelper.deepCopy(other.myUnion);
    } else {
      this.myUnion = null;
    }
  }

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

  public Long getMyIntField() {
    return this.MyIntField;
  }

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

  public String getMyStringField() {
    return this.MyStringField;
  }

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

  public MyStruct getMyStruct() {
    return this.myStruct;
  }

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

  public MyUnion getMyUnion() {
    return this.myUnion;
  }

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

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

    if (!TBaseHelper.equalsNobinary(this.isSetMyIntField(), that.isSetMyIntField(), this.MyIntField, that.MyIntField)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMyStringField(), that.isSetMyStringField(), this.MyStringField, that.MyStringField)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMyStruct(), that.isSetMyStruct(), this.myStruct, that.myStruct)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetMyUnion(), that.isSetMyUnion(), this.myUnion, that.myUnion)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {MyIntField, MyStringField, myStruct, myUnion});
  }

  // 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 MyExceptionWithMessage deserialize(TProtocol iprot) throws TException {
    Long tmp_MyIntField = null;
    String tmp_MyStringField = null;
    MyStruct tmp_myStruct = null;
    MyUnion tmp_myUnion = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case MYINTFIELD:
          if (__field.type == TType.I64) {
            tmp_MyIntField = iprot.readI64();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYSTRINGFIELD:
          if (__field.type == TType.STRING) {
            tmp_MyStringField = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYSTRUCT:
          if (__field.type == TType.STRUCT) {
            tmp_myStruct = MyStruct.deserialize(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYUNION:
          if (__field.type == TType.STRUCT) {
            tmp_myUnion = new MyUnion();
            tmp_myUnion.read(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    MyExceptionWithMessage _that;
    _that = new MyExceptionWithMessage(
      tmp_MyIntField
      ,tmp_MyStringField
      ,tmp_myStruct
      ,tmp_myUnion
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.MyIntField != null) {
      oprot.writeFieldBegin(MY_INT_FIELD_FIELD_DESC);
      oprot.writeI64(this.MyIntField);
      oprot.writeFieldEnd();
    }
    if (this.MyStringField != null) {
      oprot.writeFieldBegin(MY_STRING_FIELD_FIELD_DESC);
      oprot.writeString(this.MyStringField);
      oprot.writeFieldEnd();
    }
    if (this.myStruct != null) {
      oprot.writeFieldBegin(MY_STRUCT_FIELD_DESC);
      this.myStruct.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.myUnion != null) {
      oprot.writeFieldBegin(MY_UNION_FIELD_DESC);
      this.myUnion.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
  }

}

