/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
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 MyStructFloatFieldThrowExp implements TBase, java.io.Serializable, Cloneable, Comparable<MyStructFloatFieldThrowExp> {
  private static final TStruct STRUCT_DESC = new TStruct("MyStructFloatFieldThrowExp");
  private static final TField MY_LONG_FIELD_FIELD_DESC = new TField("myLongField", TType.I64, (short)1);
  private static final TField MY_BYTE_FIELD_FIELD_DESC = new TField("MyByteField", TType.BYTE, (short)2);
  private static final TField MY_STRING_FIELD_FIELD_DESC = new TField("myStringField", TType.STRING, (short)3);
  private static final TField MY_FLOAT_FIELD_FIELD_DESC = new TField("myFloatField", TType.FLOAT, (short)4);

  public long myLongField;
  public byte MyByteField;
  public String myStringField;
  public float myFloatField;
  public static final int MYLONGFIELD = 1;
  public static final int MYBYTEFIELD = 2;
  public static final int MYSTRINGFIELD = 3;
  public static final int MYFLOATFIELD = 4;

  // isset id assignments
  private static final int __MYLONGFIELD_ISSET_ID = 0;
  private static final int __MYBYTEFIELD_ISSET_ID = 1;
  private static final int __MYFLOATFIELD_ISSET_ID = 2;
  private BitSet __isset_bit_vector = new BitSet(3);

  public static final Map<Integer, FieldMetaData> metaDataMap;

  static {
    Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
    tmpMetaDataMap.put(MYLONGFIELD, new FieldMetaData("myLongField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(MYBYTEFIELD, new FieldMetaData("MyByteField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.BYTE)));
    tmpMetaDataMap.put(MYSTRINGFIELD, new FieldMetaData("myStringField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    tmpMetaDataMap.put(MYFLOATFIELD, new FieldMetaData("myFloatField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.FLOAT)));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

  static {
    FieldMetaData.addStructMetaDataMap(MyStructFloatFieldThrowExp.class, metaDataMap);
  }

  public MyStructFloatFieldThrowExp() {
  }

  public MyStructFloatFieldThrowExp(
      long myLongField,
      byte MyByteField,
      String myStringField,
      float myFloatField) {
    this();
    this.myLongField = myLongField;
    setMyLongFieldIsSet(true);
    this.MyByteField = MyByteField;
    setMyByteFieldIsSet(true);
    this.myStringField = myStringField;
    this.myFloatField = myFloatField;
    setMyFloatFieldIsSet(true);
  }

  public static class Builder {
    private long myLongField;
    private byte MyByteField;
    private String myStringField;
    private float myFloatField;

    BitSet __optional_isset = new BitSet(3);

    public Builder() {
    }

    public Builder setMyLongField(final long myLongField) {
      this.myLongField = myLongField;
      __optional_isset.set(__MYLONGFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setMyByteField(final byte MyByteField) {
      this.MyByteField = MyByteField;
      __optional_isset.set(__MYBYTEFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setMyStringField(final String myStringField) {
      this.myStringField = myStringField;
      return this;
    }

    public Builder setMyFloatField(final float myFloatField) {
      this.myFloatField = myFloatField;
      __optional_isset.set(__MYFLOATFIELD_ISSET_ID, true);
      return this;
    }

    public MyStructFloatFieldThrowExp build() {
      MyStructFloatFieldThrowExp result = new MyStructFloatFieldThrowExp();
      if (__optional_isset.get(__MYLONGFIELD_ISSET_ID)) {
        result.setMyLongField(this.myLongField);
      }
      if (__optional_isset.get(__MYBYTEFIELD_ISSET_ID)) {
        result.setMyByteField(this.MyByteField);
      }
      result.setMyStringField(this.myStringField);
      if (__optional_isset.get(__MYFLOATFIELD_ISSET_ID)) {
        result.setMyFloatField(this.myFloatField);
      }
      return result;
    }
  }

  public static Builder builder() {
    return new Builder();
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MyStructFloatFieldThrowExp(MyStructFloatFieldThrowExp other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.myLongField = TBaseHelper.deepCopy(other.myLongField);
    this.MyByteField = TBaseHelper.deepCopy(other.MyByteField);
    if (other.isSetMyStringField()) {
      this.myStringField = TBaseHelper.deepCopy(other.myStringField);
    }
    this.myFloatField = TBaseHelper.deepCopy(other.myFloatField);
  }

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

  public long getMyLongField() {
    return this.myLongField;
  }

  public MyStructFloatFieldThrowExp setMyLongField(long myLongField) {
    this.myLongField = myLongField;
    setMyLongFieldIsSet(true);
    return this;
  }

  public void unsetMyLongField() {
    __isset_bit_vector.clear(__MYLONGFIELD_ISSET_ID);
  }

  // Returns true if field myLongField is set (has been assigned a value) and false otherwise
  public boolean isSetMyLongField() {
    return __isset_bit_vector.get(__MYLONGFIELD_ISSET_ID);
  }

  public void setMyLongFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__MYLONGFIELD_ISSET_ID, __value);
  }

  public byte getMyByteField() {
    return this.MyByteField;
  }

  public MyStructFloatFieldThrowExp setMyByteField(byte MyByteField) {
    this.MyByteField = MyByteField;
    setMyByteFieldIsSet(true);
    return this;
  }

  public void unsetMyByteField() {
    __isset_bit_vector.clear(__MYBYTEFIELD_ISSET_ID);
  }

  // Returns true if field MyByteField is set (has been assigned a value) and false otherwise
  public boolean isSetMyByteField() {
    return __isset_bit_vector.get(__MYBYTEFIELD_ISSET_ID);
  }

  public void setMyByteFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__MYBYTEFIELD_ISSET_ID, __value);
  }

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

  public MyStructFloatFieldThrowExp setMyStringField(String myStringField) {
    this.myStringField = myStringField;
    return this;
  }

  public void unsetMyStringField() {
    this.myStringField = null;
  }

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

  public void setMyStringFieldIsSet(boolean __value) {
    if (!__value) {
      this.myStringField = null;
    }
  }

  public float getMyFloatField() {
    return this.myFloatField;
  }

  public MyStructFloatFieldThrowExp setMyFloatField(float myFloatField) {
    this.myFloatField = myFloatField;
    setMyFloatFieldIsSet(true);
    return this;
  }

  public void unsetMyFloatField() {
    __isset_bit_vector.clear(__MYFLOATFIELD_ISSET_ID);
  }

  // Returns true if field myFloatField is set (has been assigned a value) and false otherwise
  public boolean isSetMyFloatField() {
    return __isset_bit_vector.get(__MYFLOATFIELD_ISSET_ID);
  }

  public void setMyFloatFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__MYFLOATFIELD_ISSET_ID, __value);
  }

  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case MYLONGFIELD:
      if (__value == null) {
        unsetMyLongField();
      } else {
        setMyLongField((Long)__value);
      }
      break;

    case MYBYTEFIELD:
      if (__value == null) {
        unsetMyByteField();
      } else {
        setMyByteField((Byte)__value);
      }
      break;

    case MYSTRINGFIELD:
      if (__value == null) {
        unsetMyStringField();
      } else {
        setMyStringField((String)__value);
      }
      break;

    case MYFLOATFIELD:
      if (__value == null) {
        unsetMyFloatField();
      } else {
        setMyFloatField((Float)__value);
      }
      break;

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case MYLONGFIELD:
      return new Long(getMyLongField());

    case MYBYTEFIELD:
      return new Byte(getMyByteField());

    case MYSTRINGFIELD:
      return getMyStringField();

    case MYFLOATFIELD:
      return new Float(getMyFloatField());

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

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

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

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

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

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

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {myLongField, MyByteField, myStringField, myFloatField});
  }

  @Override
  public int compareTo(MyStructFloatFieldThrowExp other) {
    if (other == null) {
      // See java.lang.Comparable docs
      throw new NullPointerException();
    }

    if (other == this) {
      return 0;
    }
    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetMyLongField()).compareTo(other.isSetMyLongField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(myLongField, other.myLongField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMyByteField()).compareTo(other.isSetMyByteField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(MyByteField, other.MyByteField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMyStringField()).compareTo(other.isSetMyStringField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(myStringField, other.myStringField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMyFloatField()).compareTo(other.isSetMyFloatField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(myFloatField, other.myFloatField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField __field;
    iprot.readStructBegin(metaDataMap);
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case MYLONGFIELD:
          if (__field.type == TType.I64) {
            this.myLongField = iprot.readI64();
            setMyLongFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYBYTEFIELD:
          if (__field.type == TType.BYTE) {
            this.MyByteField = iprot.readByte();
            setMyByteFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYSTRINGFIELD:
          if (__field.type == TType.STRING) {
            this.myStringField = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MYFLOATFIELD:
          if (__field.type == TType.FLOAT) {
            this.myFloatField = iprot.readFloat();
            setMyFloatFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();


    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(MY_LONG_FIELD_FIELD_DESC);
    oprot.writeI64(this.myLongField);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(MY_BYTE_FIELD_FIELD_DESC);
    oprot.writeByte(this.MyByteField);
    oprot.writeFieldEnd();
    if (this.myStringField != null) {
      oprot.writeFieldBegin(MY_STRING_FIELD_FIELD_DESC);
      oprot.writeString(this.myStringField);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(MY_FLOAT_FIELD_FIELD_DESC);
    oprot.writeFloat(this.myFloatField);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

  @Override
  public String toString(int indent, boolean prettyPrint) {
    String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : "";
    String newLine = prettyPrint ? "\n" : "";
    String space = prettyPrint ? " " : "";
    StringBuilder sb = new StringBuilder("MyStructFloatFieldThrowExp");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("myLongField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getMyLongField(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("MyByteField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getMyByteField(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("myStringField");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getMyStringField() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getMyStringField(), indent + 1, prettyPrint));
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("myFloatField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getMyFloatField(), indent + 1, prettyPrint));
    first = false;
    sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
    sb.append(")");
    return sb.toString();
  }

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

}

