/**
 * 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 MyStruct implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("MyStruct");
  private static final TField MAJOR_FIELD_DESC = new TField("major", TType.I64, (short)2);
  private static final TField ABSTRACT_FIELD_DESC = new TField("abstract", TType.STRING, (short)1);
  private static final TField ANNOTATION_WITH_QUOTE_FIELD_DESC = new TField("annotation_with_quote", TType.STRING, (short)3);
  private static final TField CLASS__FIELD_DESC = new TField("class_", TType.STRING, (short)4);
  private static final TField ANNOTATION_WITH_TRAILING_COMMA_FIELD_DESC = new TField("annotation_with_trailing_comma", TType.STRING, (short)5);
  private static final TField EMPTY_ANNOTATIONS_FIELD_DESC = new TField("empty_annotations", TType.STRING, (short)6);
  private static final TField MY_ENUM_FIELD_DESC = new TField("my_enum", TType.I32, (short)7);
  private static final TField CPP_TYPE_ANNOTATION_FIELD_DESC = new TField("cpp_type_annotation", TType.LIST, (short)8);
  private static final TField MY_UNION_FIELD_DESC = new TField("my_union", TType.STRUCT, (short)9);

  public final Long major;
  public final String abstract;
  public final String annotation_with_quote;
  public final String class_;
  public final String annotation_with_trailing_comma;
  public final String empty_annotations;
  /**
   * 
   * @see MyEnum
   */
  public final MyEnum my_enum;
  public final List<String> cpp_type_annotation;
  public final MyUnion my_union;
  public static final int MAJOR = 2;
  public static final int ABSTRACT = 1;
  public static final int ANNOTATION_WITH_QUOTE = 3;
  public static final int CLASS_ = 4;
  public static final int ANNOTATION_WITH_TRAILING_COMMA = 5;
  public static final int EMPTY_ANNOTATIONS = 6;
  public static final int MY_ENUM = 7;
  public static final int CPP_TYPE_ANNOTATION = 8;
  public static final int MY_UNION = 9;

  public MyStruct(
      Long major,
      String abstract,
      String annotation_with_quote,
      String class_,
      String annotation_with_trailing_comma,
      String empty_annotations,
      MyEnum my_enum,
      List<String> cpp_type_annotation,
      MyUnion my_union) {
    this.major = major;
    this.abstract = abstract;
    this.annotation_with_quote = annotation_with_quote;
    this.class_ = class_;
    this.annotation_with_trailing_comma = annotation_with_trailing_comma;
    this.empty_annotations = empty_annotations;
    this.my_enum = my_enum;
    this.cpp_type_annotation = cpp_type_annotation;
    this.my_union = my_union;
  }

  public static class Builder {
    private Long major;
    private String abstract;
    private String annotation_with_quote;
    private String class_;
    private String annotation_with_trailing_comma;
    private String empty_annotations;
    private MyEnum my_enum;
    private List<String> cpp_type_annotation;
    private MyUnion my_union;

    public Builder() {
    }

    public Builder setMajor(final Long major) {
      this.major = major;
      return this;
    }

    public Builder setAbstract(final String abstract) {
      this.abstract = abstract;
      return this;
    }

    public Builder setAnnotation_with_quote(final String annotation_with_quote) {
      this.annotation_with_quote = annotation_with_quote;
      return this;
    }

    public Builder setClass_(final String class_) {
      this.class_ = class_;
      return this;
    }

    public Builder setAnnotation_with_trailing_comma(final String annotation_with_trailing_comma) {
      this.annotation_with_trailing_comma = annotation_with_trailing_comma;
      return this;
    }

    public Builder setEmpty_annotations(final String empty_annotations) {
      this.empty_annotations = empty_annotations;
      return this;
    }

    public Builder setMy_enum(final MyEnum my_enum) {
      this.my_enum = my_enum;
      return this;
    }

    public Builder setCpp_type_annotation(final List<String> cpp_type_annotation) {
      this.cpp_type_annotation = cpp_type_annotation;
      return this;
    }

    public Builder setMy_union(final MyUnion my_union) {
      this.my_union = my_union;
      return this;
    }

    public MyStruct build() {
      return new MyStruct(
        this.major,
        this.abstract,
        this.annotation_with_quote,
        this.class_,
        this.annotation_with_trailing_comma,
        this.empty_annotations,
        this.my_enum,
        this.cpp_type_annotation,
        this.my_union
      );
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MyStruct(MyStruct other) {
    if (other.isSetMajor()) {
      this.major = TBaseHelper.deepCopy(other.major);
    } else {
      this.major = null;
    }
    if (other.isSetAbstract()) {
      this.abstract = TBaseHelper.deepCopy(other.abstract);
    } else {
      this.abstract = null;
    }
    if (other.isSetAnnotation_with_quote()) {
      this.annotation_with_quote = TBaseHelper.deepCopy(other.annotation_with_quote);
    } else {
      this.annotation_with_quote = null;
    }
    if (other.isSetClass_()) {
      this.class_ = TBaseHelper.deepCopy(other.class_);
    } else {
      this.class_ = null;
    }
    if (other.isSetAnnotation_with_trailing_comma()) {
      this.annotation_with_trailing_comma = TBaseHelper.deepCopy(other.annotation_with_trailing_comma);
    } else {
      this.annotation_with_trailing_comma = null;
    }
    if (other.isSetEmpty_annotations()) {
      this.empty_annotations = TBaseHelper.deepCopy(other.empty_annotations);
    } else {
      this.empty_annotations = null;
    }
    if (other.isSetMy_enum()) {
      this.my_enum = TBaseHelper.deepCopy(other.my_enum);
    } else {
      this.my_enum = null;
    }
    if (other.isSetCpp_type_annotation()) {
      this.cpp_type_annotation = TBaseHelper.deepCopy(other.cpp_type_annotation);
    } else {
      this.cpp_type_annotation = null;
    }
    if (other.isSetMy_union()) {
      this.my_union = TBaseHelper.deepCopy(other.my_union);
    } else {
      this.my_union = null;
    }
  }

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

  public Long getMajor() {
    return this.major;
  }

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

  public String getAbstract() {
    return this.abstract;
  }

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

  public String getAnnotation_with_quote() {
    return this.annotation_with_quote;
  }

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

  public String getClass_() {
    return this.class_;
  }

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

  public String getAnnotation_with_trailing_comma() {
    return this.annotation_with_trailing_comma;
  }

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

  public String getEmpty_annotations() {
    return this.empty_annotations;
  }

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

  /**
   * 
   * @see MyEnum
   */
  public MyEnum getMy_enum() {
    return this.my_enum;
  }

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

  public List<String> getCpp_type_annotation() {
    return this.cpp_type_annotation;
  }

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

  public MyUnion getMy_union() {
    return this.my_union;
  }

  // Returns true if field my_union is set (has been assigned a value) and false otherwise
  public boolean isSetMy_union() {
    return this.my_union != 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.isSetMajor(), that.isSetMajor(), this.major, that.major)) { return false; }

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

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

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

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

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

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

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

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

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {major, abstract, annotation_with_quote, class_, annotation_with_trailing_comma, empty_annotations, my_enum, cpp_type_annotation, my_union});
  }

  // 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 {
    Long tmp_major = null;
    String tmp_abstract = null;
    String tmp_annotation_with_quote = null;
    String tmp_class_ = null;
    String tmp_annotation_with_trailing_comma = null;
    String tmp_empty_annotations = null;
    MyEnum tmp_my_enum = null;
    List<String> tmp_cpp_type_annotation = null;
    MyUnion tmp_my_union = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case MAJOR:
          if (__field.type == TType.I64) {
            tmp_major = iprot.readI64();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ABSTRACT:
          if (__field.type == TType.STRING) {
            tmp_abstract = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ANNOTATION_WITH_QUOTE:
          if (__field.type == TType.STRING) {
            tmp_annotation_with_quote = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case CLASS_:
          if (__field.type == TType.STRING) {
            tmp_class_ = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ANNOTATION_WITH_TRAILING_COMMA:
          if (__field.type == TType.STRING) {
            tmp_annotation_with_trailing_comma = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case EMPTY_ANNOTATIONS:
          if (__field.type == TType.STRING) {
            tmp_empty_annotations = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MY_ENUM:
          if (__field.type == TType.I32) {
            tmp_my_enum = MyEnum.findByValue(iprot.readI32());
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case CPP_TYPE_ANNOTATION:
          if (__field.type == TType.LIST) {
            {
              TList _list0 = iprot.readListBegin();
              tmp_cpp_type_annotation = new ArrayList<String>(Math.max(0, _list0.size));
              for (int _i1 = 0; 
                   (_list0.size < 0) ? iprot.peekList() : (_i1 < _list0.size); 
                   ++_i1)
              {
                String _elem2;
                _elem2 = iprot.readString();
                tmp_cpp_type_annotation.add(_elem2);
              }
              iprot.readListEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MY_UNION:
          if (__field.type == TType.STRUCT) {
            tmp_my_union = new MyUnion();
            tmp_my_union.read(iprot);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    MyStruct _that;
    _that = new MyStruct(
      tmp_major
      ,tmp_abstract
      ,tmp_annotation_with_quote
      ,tmp_class_
      ,tmp_annotation_with_trailing_comma
      ,tmp_empty_annotations
      ,tmp_my_enum
      ,tmp_cpp_type_annotation
      ,tmp_my_union
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.abstract != null) {
      oprot.writeFieldBegin(ABSTRACT_FIELD_DESC);
      oprot.writeString(this.abstract);
      oprot.writeFieldEnd();
    }
    if (this.major != null) {
      oprot.writeFieldBegin(MAJOR_FIELD_DESC);
      oprot.writeI64(this.major);
      oprot.writeFieldEnd();
    }
    if (this.annotation_with_quote != null) {
      oprot.writeFieldBegin(ANNOTATION_WITH_QUOTE_FIELD_DESC);
      oprot.writeString(this.annotation_with_quote);
      oprot.writeFieldEnd();
    }
    if (this.class_ != null) {
      oprot.writeFieldBegin(CLASS__FIELD_DESC);
      oprot.writeString(this.class_);
      oprot.writeFieldEnd();
    }
    if (this.annotation_with_trailing_comma != null) {
      oprot.writeFieldBegin(ANNOTATION_WITH_TRAILING_COMMA_FIELD_DESC);
      oprot.writeString(this.annotation_with_trailing_comma);
      oprot.writeFieldEnd();
    }
    if (this.empty_annotations != null) {
      oprot.writeFieldBegin(EMPTY_ANNOTATIONS_FIELD_DESC);
      oprot.writeString(this.empty_annotations);
      oprot.writeFieldEnd();
    }
    if (this.my_enum != null) {
      oprot.writeFieldBegin(MY_ENUM_FIELD_DESC);
      oprot.writeI32(this.my_enum == null ? 0 : this.my_enum.getValue());
      oprot.writeFieldEnd();
    }
    if (this.cpp_type_annotation != null) {
      oprot.writeFieldBegin(CPP_TYPE_ANNOTATION_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.cpp_type_annotation.size()));
        for (String _iter3 : this.cpp_type_annotation)        {
          oprot.writeString(_iter3);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.my_union != null) {
      oprot.writeFieldBegin(MY_UNION_FIELD_DESC);
      this.my_union.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
  }

}

