/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package com.twitter.scrooge.test.gold.thriftjava;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;

import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;

import com.twitter.scrooge.ThriftStructIface;
import com.twitter.scrooge.UtilValidator;
import com.twitter.scrooge.thrift_validation.BaseValidator;
import com.twitter.scrooge.thrift_validation.ThriftValidationViolation;
import com.twitter.scrooge.TFieldBlob;
import com.twitter.scrooge.internal.TProtocols;

// No additional import required for struct/union.

public class Request implements TBase<Request, Request._Fields>, java.io.Serializable, Cloneable, ThriftStructIface {
  private static final TStruct STRUCT_DESC = new TStruct("Request");

  private static final TField A_LIST_FIELD_DESC = new TField("aList", TType.LIST, (short)1);
  private static final TField A_SET_FIELD_DESC = new TField("aSet", TType.SET, (short)2);
  private static final TField A_MAP_FIELD_DESC = new TField("aMap", TType.MAP, (short)3);
  private static final TField A_REQUEST_FIELD_DESC = new TField("aRequest", TType.STRUCT, (short)4);
  private static final TField SUB_REQUESTS_FIELD_DESC = new TField("subRequests", TType.LIST, (short)5);
  private static final TField _DEFAULT_FIELD_DESC = new TField("_default", TType.STRING, (short)6);
  private static final TField NO_COMMENT_FIELD_DESC = new TField("noComment", TType.I64, (short)7);
  private static final TField DOUBLE_SLASH_COMMENT_FIELD_DESC = new TField("doubleSlashComment", TType.I64, (short)8);
  private static final TField HASHTAG_COMMENT_FIELD_DESC = new TField("hashtagComment", TType.I64, (short)9);
  private static final TField SINGLE_ASTERISK_COMMENT_FIELD_DESC = new TField("singleAsteriskComment", TType.I64, (short)10);
  private static final TField DOC_STRING_COMMENT_FIELD_DESC = new TField("docStringComment", TType.I64, (short)11);
  private static final TField REC_REQUEST_FIELD_DESC = new TField("recRequest", TType.STRUCT, (short)12);
  private static final TField REQUIRED_FIELD_FIELD_DESC = new TField("requiredField", TType.STRING, (short)13);
  private static final TField CONSTRUCTION_REQUIRED_FIELD_FIELD_DESC = new TField("constructionRequiredField", TType.I64, (short)14);
  private static final TField AN_INT8_FIELD_DESC = new TField("anInt8", TType.BYTE, (short)15);
  private static final TField A_BINARY_FIELD_FIELD_DESC = new TField("aBinaryField", TType.STRING, (short)16);


  public List<String> aList;
  public Set<Integer> aSet;
  public Map<Long,Long> aMap;
  public Request aRequest;
  public List<Request> subRequests;
  public String _default;
  public long noComment;
  public long doubleSlashComment;
  public long hashtagComment;
  public long singleAsteriskComment;
  public long docStringComment;
  public Recursive recRequest;
  public String requiredField;
  public long constructionRequiredField;
  public byte anInt8;
  public ByteBuffer aBinaryField;
  private Map<Short, TFieldBlob> passThroughFields;

  /** The set of fields this object contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    A_LIST((short)1, "aList"),
    A_SET((short)2, "aSet"),
    A_MAP((short)3, "aMap"),
    A_REQUEST((short)4, "aRequest"),
    SUB_REQUESTS((short)5, "subRequests"),
    _DEFAULT((short)6, "_default"),
    NO_COMMENT((short)7, "noComment"),
    DOUBLE_SLASH_COMMENT((short)8, "doubleSlashComment"),
    HASHTAG_COMMENT((short)9, "hashtagComment"),
    SINGLE_ASTERISK_COMMENT((short)10, "singleAsteriskComment"),
    DOC_STRING_COMMENT((short)11, "docStringComment"),
    REC_REQUEST((short)12, "recRequest"),
    REQUIRED_FIELD((short)13, "requiredField"),
    CONSTRUCTION_REQUIRED_FIELD((short)14, "constructionRequiredField"),
    AN_INT8((short)15, "anInt8"),
    A_BINARY_FIELD((short)16, "aBinaryField");
  
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
  
    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }
  
    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // A_LIST
          return A_LIST;
        case 2: // A_SET
          return A_SET;
        case 3: // A_MAP
          return A_MAP;
        case 4: // A_REQUEST
          return A_REQUEST;
        case 5: // SUB_REQUESTS
          return SUB_REQUESTS;
        case 6: // _DEFAULT
          return _DEFAULT;
        case 7: // NO_COMMENT
          return NO_COMMENT;
        case 8: // DOUBLE_SLASH_COMMENT
          return DOUBLE_SLASH_COMMENT;
        case 9: // HASHTAG_COMMENT
          return HASHTAG_COMMENT;
        case 10: // SINGLE_ASTERISK_COMMENT
          return SINGLE_ASTERISK_COMMENT;
        case 11: // DOC_STRING_COMMENT
          return DOC_STRING_COMMENT;
        case 12: // REC_REQUEST
          return REC_REQUEST;
        case 13: // REQUIRED_FIELD
          return REQUIRED_FIELD;
        case 14: // CONSTRUCTION_REQUIRED_FIELD
          return CONSTRUCTION_REQUIRED_FIELD;
        case 15: // AN_INT8
          return AN_INT8;
        case 16: // A_BINARY_FIELD
          return A_BINARY_FIELD;
        default:
          return null;
      }
    }
  
    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }
  
    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }
  
    private final short _thriftId;
    private final String _fieldName;
  
    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }
  
    public short getThriftFieldId() {
      return _thriftId;
    }
  
    public String getFieldName() {
      return _fieldName;
    }
  }


  // isset id assignments
  private static final int __NOCOMMENT_ISSET_ID = 0;
  private static final int __DOUBLESLASHCOMMENT_ISSET_ID = 1;
  private static final int __HASHTAGCOMMENT_ISSET_ID = 2;
  private static final int __SINGLEASTERISKCOMMENT_ISSET_ID = 3;
  private static final int __DOCSTRINGCOMMENT_ISSET_ID = 4;
  private static final int __CONSTRUCTIONREQUIREDFIELD_ISSET_ID = 5;
  private static final int __ANINT8_ISSET_ID = 6;
  private final BitSet __isset_bit_vector = new BitSet(7);

  public static final Map<_Fields, FieldMetaData> metaDataMap;
  
  /**
   * FieldValueMetaData.type returns TType.STRING for both string and binary field values.
   * This set can be used to determine if a FieldValueMetaData with type TType.STRING is actually
   * declared as binary in the idl file.
   */
  public static final Set<FieldValueMetaData> binaryFieldValueMetaDatas;
  
  private static FieldValueMetaData registerBinaryFieldValueMetaData(FieldValueMetaData f, Set<FieldValueMetaData> binaryFieldValues) {
    binaryFieldValues.add(f);
    return f;
  }
  
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    Set<FieldValueMetaData> tmpSet = new HashSet<FieldValueMetaData>();
    tmpMap.put(_Fields.A_LIST, new FieldMetaData("aList", TFieldRequirementType.DEFAULT,
      new ListMetaData(TType.LIST,
                new FieldValueMetaData(TType.STRING))));
    tmpMap.put(_Fields.A_SET, new FieldMetaData("aSet", TFieldRequirementType.DEFAULT,
      new SetMetaData(TType.SET,
                new FieldValueMetaData(TType.I32))));
    tmpMap.put(_Fields.A_MAP, new FieldMetaData("aMap", TFieldRequirementType.DEFAULT,
      new MapMetaData(TType.MAP,
            new FieldValueMetaData(TType.I64),
            new FieldValueMetaData(TType.I64))));
    tmpMap.put(_Fields.A_REQUEST, new FieldMetaData("aRequest", TFieldRequirementType.OPTIONAL,
      new StructMetaData(TType.STRUCT, Request.class)));
    tmpMap.put(_Fields.SUB_REQUESTS, new FieldMetaData("subRequests", TFieldRequirementType.DEFAULT,
      new ListMetaData(TType.LIST,
                new StructMetaData(TType.STRUCT, Request.class))));
    tmpMap.put(_Fields._DEFAULT, new FieldMetaData("_default", TFieldRequirementType.DEFAULT,
      new FieldValueMetaData(TType.STRING)));
    tmpMap.put(_Fields.NO_COMMENT, new FieldMetaData("noComment", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.DOUBLE_SLASH_COMMENT, new FieldMetaData("doubleSlashComment", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.HASHTAG_COMMENT, new FieldMetaData("hashtagComment", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.SINGLE_ASTERISK_COMMENT, new FieldMetaData("singleAsteriskComment", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.DOC_STRING_COMMENT, new FieldMetaData("docStringComment", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.REC_REQUEST, new FieldMetaData("recRequest", TFieldRequirementType.OPTIONAL,
      new StructMetaData(TType.STRUCT, Recursive.class)));
    tmpMap.put(_Fields.REQUIRED_FIELD, new FieldMetaData("requiredField", TFieldRequirementType.REQUIRED,
      new FieldValueMetaData(TType.STRING)));
    tmpMap.put(_Fields.CONSTRUCTION_REQUIRED_FIELD, new FieldMetaData("constructionRequiredField", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.AN_INT8, new FieldMetaData("anInt8", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.BYTE)));
    tmpMap.put(_Fields.A_BINARY_FIELD, new FieldMetaData("aBinaryField", TFieldRequirementType.OPTIONAL,
      registerBinaryFieldValueMetaData(new FieldValueMetaData(TType.STRING, true), tmpSet)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    binaryFieldValueMetaDatas = Collections.unmodifiableSet(tmpSet);
    FieldMetaData.addStructMetaDataMap(Request.class, metaDataMap);
  }

  /**
   * Returns a map of the annotations and their values for this struct declaration.
   * See fieldAnnotations or valueAnnotations for the annotations attached to struct fields
   * or enum values.
   */
  public static final Map<String, String> structAnnotations;
  static {
    Map<String, String> tmpMap = new HashMap<String, String>();
    tmpMap.put("s.annotation.one", "something");
    tmpMap.put("s.annotation.two", "other");
    tmpMap.put("com.twitter.scrooge.scala.generateStructProxy", "true");
    structAnnotations = Collections.unmodifiableMap(tmpMap);
  }

  /**
   * Returns a map of the annotations for each of this struct's fields, keyed by the field.
   * See structAnnotations for the annotations attached to this struct's declaration.
   */
  public static final Map<_Fields, Map<String, String>> fieldAnnotations;
  static {
    Map<_Fields, Map<String, String>> tmpMap = new EnumMap<_Fields, Map<String, String>>(_Fields.class);
      {
        Map<String, String> tmpFieldMap = new HashMap<String, String>();
        tmpFieldMap.put("a.b.c", "ignored");
        tmpMap.put(_Fields.HASHTAG_COMMENT, Collections.unmodifiableMap(tmpFieldMap));
      }
      {
        Map<String, String> tmpFieldMap = new HashMap<String, String>();
        tmpFieldMap.put("s.field.annotation.one", "a");
        tmpFieldMap.put("two", "b");
        tmpMap.put(_Fields.SINGLE_ASTERISK_COMMENT, Collections.unmodifiableMap(tmpFieldMap));
      }
      {
        Map<String, String> tmpFieldMap = new HashMap<String, String>();
        tmpFieldMap.put("validation.length.min", "6");
        tmpMap.put(_Fields.REQUIRED_FIELD, Collections.unmodifiableMap(tmpFieldMap));
      }
      {
        Map<String, String> tmpFieldMap = new HashMap<String, String>();
        tmpFieldMap.put("construction_required", "true");
        tmpMap.put(_Fields.CONSTRUCTION_REQUIRED_FIELD, Collections.unmodifiableMap(tmpFieldMap));
      }
    fieldAnnotations = Collections.unmodifiableMap(tmpMap);
  }

  /**
   * Returns the set of fields that have a configured default value.
   * The default values for these fields can be obtained by
   * instantiating this class with the default constructor.
   */
  public static final Set<_Fields> hasDefaultValue;
  static {
    Set<_Fields> tmp = EnumSet.noneOf(_Fields.class);
    tmp.add(_Fields._DEFAULT);
    hasDefaultValue = Collections.unmodifiableSet(tmp);
  }


  public Request() {
    this._default = "the_default";
  }

  public Request(
    List<String> aList,
    Set<Integer> aSet,
    Map<Long,Long> aMap,
    List<Request> subRequests,
    String _default,
    String requiredField,
    long constructionRequiredField)
  {
    this();
    this.aList = aList;
    this.aSet = aSet;
    this.aMap = aMap;
    this.subRequests = subRequests;
    this._default = _default;
    this.requiredField = requiredField;
    this.constructionRequiredField = constructionRequiredField;
    setConstructionRequiredFieldIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Request(Request other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetAList()) {
      int __this__aList_size = other.aList.size();
      List<String> __this__aList = new ArrayList<String>(__this__aList_size);
      for (String other_element : other.aList) {
        __this__aList.add(other_element);
      }
      this.aList = __this__aList;
    }
    if (other.isSetASet()) {
      int __this__aSet_size = (int) ((float) other.aSet.size() / 0.75F + 1.0F);
      Set<Integer> __this__aSet = new HashSet<Integer>(__this__aSet_size);
      for (Integer other_element : other.aSet) {
        __this__aSet.add(other_element);
      }
      this.aSet = __this__aSet;
    }
    if (other.isSetAMap()) {
      int __this__aMap_size = (int) ((float) other.aMap.size() / 0.75F + 1.0F);
      Map<Long,Long> __this__aMap = new HashMap<Long,Long>(__this__aMap_size);
      for (Map.Entry<Long, Long> other_element : other.aMap.entrySet()) {
        Long other_element_key = other_element.getKey();
        Long other_element_value = other_element.getValue();
        Long __this__aMap_copy_key = other_element_key;
        Long __this__aMap_copy_value = other_element_value;
        __this__aMap.put(__this__aMap_copy_key, __this__aMap_copy_value);
      }
      this.aMap = __this__aMap;
    }
    if (other.isSetARequest()) {
      this.aRequest = new Request(other.aRequest);
    }
    if (other.isSetSubRequests()) {
      int __this__subRequests_size = other.subRequests.size();
      List<Request> __this__subRequests = new ArrayList<Request>(__this__subRequests_size);
      for (Request other_element : other.subRequests) {
        __this__subRequests.add(new Request(other_element));
      }
      this.subRequests = __this__subRequests;
    }
    if (other.isSet_default()) {
      this._default = other._default;
    }
    this.noComment = other.noComment;
    this.doubleSlashComment = other.doubleSlashComment;
    this.hashtagComment = other.hashtagComment;
    this.singleAsteriskComment = other.singleAsteriskComment;
    this.docStringComment = other.docStringComment;
    if (other.isSetRecRequest()) {
      this.recRequest = new Recursive(other.recRequest);
    }
    if (other.isSetRequiredField()) {
      this.requiredField = other.requiredField;
    }
    this.constructionRequiredField = other.constructionRequiredField;
    this.anInt8 = other.anInt8;
    if (other.isSetABinaryField()) {
      this.aBinaryField = TBaseHelper.copyBinary(other.aBinaryField);
    }
    this.passThroughFields = other.passThroughFields;
  }

  public static List<String> validateNewInstance(Request item) {
    final List<String> buf = new ArrayList<String>();

    if (item.isSetARequest()) {
      Request _aRequest = item.aRequest;
      buf.addAll(com.twitter.scrooge.test.gold.thriftjava.Request.validateNewInstance(_aRequest));
    }

    if (item.isSetSubRequests()) {
      List<Request> _subRequests = item.subRequests;
      for (Request _subRequests_element : _subRequests) {
        buf.addAll(com.twitter.scrooge.test.gold.thriftjava.Request.validateNewInstance(_subRequests_element));
      }
    }

    if (item.isSetRecRequest()) {
      Recursive _recRequest = item.recRequest;
      buf.addAll(com.twitter.scrooge.test.gold.thriftjava.Recursive.validateNewInstance(_recRequest));
    }

    if (!item.isSetRequiredField()) {
       buf.add("Required field 'requiredField' in type 'Request' was not present.");
    }

    if (!item.isSetConstructionRequiredField()) {
      buf.add("Construction required field 'constructionRequiredField' in type 'Request' was not present.");
    }

    return buf;
  }

  public static Set<ThriftValidationViolation> validateInstanceValue(Request item) {
    final Set<ThriftValidationViolation> violations = new HashSet<ThriftValidationViolation>();
    final BaseValidator validator = new UtilValidator();

    violations.addAll(com.twitter.scrooge.test.gold.thriftjava.Request.validateInstanceValue(item.aRequest));
    violations.addAll(validator.validateField("hashtagComment", item.hashtagComment, fieldAnnotations.get(_Fields.HASHTAG_COMMENT)));
    violations.addAll(validator.validateField("singleAsteriskComment", item.singleAsteriskComment, fieldAnnotations.get(_Fields.SINGLE_ASTERISK_COMMENT)));
    violations.addAll(com.twitter.scrooge.test.gold.thriftjava.Recursive.validateInstanceValue(item.recRequest));
    violations.addAll(validator.validateField("requiredField", item.requiredField, fieldAnnotations.get(_Fields.REQUIRED_FIELD)));
    violations.addAll(validator.validateField("constructionRequiredField", item.constructionRequiredField, fieldAnnotations.get(_Fields.CONSTRUCTION_REQUIRED_FIELD)));

    return violations;
  }

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

  @java.lang.Override
  public void clear() {
    this.aList = null;
    this.aSet = null;
    this.aMap = null;
    this.aRequest = null;
    this.subRequests = null;
    this._default = "the_default";
    setNoCommentIsSet(false);
    this.noComment = 0;
    setDoubleSlashCommentIsSet(false);
    this.doubleSlashComment = 0;
    setHashtagCommentIsSet(false);
    this.hashtagComment = 0;
    setSingleAsteriskCommentIsSet(false);
    this.singleAsteriskComment = 0;
    setDocStringCommentIsSet(false);
    this.docStringComment = 0;
    this.recRequest = null;
    this.requiredField = null;
    setConstructionRequiredFieldIsSet(false);
    this.constructionRequiredField = 0;
    setAnInt8IsSet(false);
    this.anInt8 = 0;
    this.aBinaryField = null;
    this.passThroughFields = null;
  }

  public int getAListSize() {
    return (this.aList == null) ? 0 : this.aList.size();
  }

  public java.util.Iterator<String> getAListIterator() {
    return (this.aList == null) ? null : this.aList.iterator();
  }

  public void addToAList(String elem) {
    if (this.aList == null) {
      this.aList = new ArrayList<String>();
    }
    this.aList.add(elem);
  }

  public List<String> getAList() {
    return this.aList;
  }

  public Request setAList(List<String> aList) {
    this.aList = aList;
    
    return this;
  }

  public void unsetAList() {
    this.aList = null;
  }

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

  public void setAListIsSet(boolean value) {
    if (!value) {
      this.aList = null;
    }
  }

  public int getASetSize() {
    return (this.aSet == null) ? 0 : this.aSet.size();
  }

  public java.util.Iterator<Integer> getASetIterator() {
    return (this.aSet == null) ? null : this.aSet.iterator();
  }

  public void addToASet(int elem) {
    if (this.aSet == null) {
      this.aSet = new HashSet<Integer>();
    }
    this.aSet.add(elem);
  }

  public Set<Integer> getASet() {
    return this.aSet;
  }

  public Request setASet(Set<Integer> aSet) {
    this.aSet = aSet;
    
    return this;
  }

  public void unsetASet() {
    this.aSet = null;
  }

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

  public void setASetIsSet(boolean value) {
    if (!value) {
      this.aSet = null;
    }
  }

  public int getAMapSize() {
    return (this.aMap == null) ? 0 : this.aMap.size();
  }

  public void putToAMap(long key, long val) {
    if (this.aMap == null) {
      this.aMap = new HashMap<Long,Long>();
    }
    this.aMap.put(key, val);
  }

  public Map<Long,Long> getAMap() {
    return this.aMap;
  }

  public Request setAMap(Map<Long,Long> aMap) {
    this.aMap = aMap;
    
    return this;
  }

  public void unsetAMap() {
    this.aMap = null;
  }

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

  public void setAMapIsSet(boolean value) {
    if (!value) {
      this.aMap = null;
    }
  }

  public Request getARequest() {
    return this.aRequest;
  }

  public Request setARequest(Request aRequest) {
    this.aRequest = aRequest;
    
    return this;
  }

  public void unsetARequest() {
    this.aRequest = null;
  }

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

  public void setARequestIsSet(boolean value) {
    if (!value) {
      this.aRequest = null;
    }
  }

  public int getSubRequestsSize() {
    return (this.subRequests == null) ? 0 : this.subRequests.size();
  }

  public java.util.Iterator<Request> getSubRequestsIterator() {
    return (this.subRequests == null) ? null : this.subRequests.iterator();
  }

  public void addToSubRequests(Request elem) {
    if (this.subRequests == null) {
      this.subRequests = new ArrayList<Request>();
    }
    this.subRequests.add(elem);
  }

  public List<Request> getSubRequests() {
    return this.subRequests;
  }

  public Request setSubRequests(List<Request> subRequests) {
    this.subRequests = subRequests;
    
    return this;
  }

  public void unsetSubRequests() {
    this.subRequests = null;
  }

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

  public void setSubRequestsIsSet(boolean value) {
    if (!value) {
      this.subRequests = null;
    }
  }

  public String get_default() {
    return this._default;
  }

  public Request set_default(String _default) {
    this._default = _default;
    
    return this;
  }

  public void unset_default() {
    this._default = null;
  }

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

  public void set_defaultIsSet(boolean value) {
    if (!value) {
      this._default = null;
    }
  }

  public long getNoComment() {
    return this.noComment;
  }

  public Request setNoComment(long noComment) {
    this.noComment = noComment;
    setNoCommentIsSet(true);

    return this;
  }

  public void unsetNoComment() {
  __isset_bit_vector.clear(__NOCOMMENT_ISSET_ID);
  }

  /** Returns true if field noComment is set (has been assigned a value) and false otherwise */
  public boolean isSetNoComment() {
    return __isset_bit_vector.get(__NOCOMMENT_ISSET_ID);
  }

  public void setNoCommentIsSet(boolean value) {
    __isset_bit_vector.set(__NOCOMMENT_ISSET_ID, value);
  }

  public long getDoubleSlashComment() {
    return this.doubleSlashComment;
  }

  public Request setDoubleSlashComment(long doubleSlashComment) {
    this.doubleSlashComment = doubleSlashComment;
    setDoubleSlashCommentIsSet(true);

    return this;
  }

  public void unsetDoubleSlashComment() {
  __isset_bit_vector.clear(__DOUBLESLASHCOMMENT_ISSET_ID);
  }

  /** Returns true if field doubleSlashComment is set (has been assigned a value) and false otherwise */
  public boolean isSetDoubleSlashComment() {
    return __isset_bit_vector.get(__DOUBLESLASHCOMMENT_ISSET_ID);
  }

  public void setDoubleSlashCommentIsSet(boolean value) {
    __isset_bit_vector.set(__DOUBLESLASHCOMMENT_ISSET_ID, value);
  }

  public long getHashtagComment() {
    return this.hashtagComment;
  }

  public Request setHashtagComment(long hashtagComment) {
    this.hashtagComment = hashtagComment;
    setHashtagCommentIsSet(true);

    return this;
  }

  public void unsetHashtagComment() {
  __isset_bit_vector.clear(__HASHTAGCOMMENT_ISSET_ID);
  }

  /** Returns true if field hashtagComment is set (has been assigned a value) and false otherwise */
  public boolean isSetHashtagComment() {
    return __isset_bit_vector.get(__HASHTAGCOMMENT_ISSET_ID);
  }

  public void setHashtagCommentIsSet(boolean value) {
    __isset_bit_vector.set(__HASHTAGCOMMENT_ISSET_ID, value);
  }

  public long getSingleAsteriskComment() {
    return this.singleAsteriskComment;
  }

  public Request setSingleAsteriskComment(long singleAsteriskComment) {
    this.singleAsteriskComment = singleAsteriskComment;
    setSingleAsteriskCommentIsSet(true);

    return this;
  }

  public void unsetSingleAsteriskComment() {
  __isset_bit_vector.clear(__SINGLEASTERISKCOMMENT_ISSET_ID);
  }

  /** Returns true if field singleAsteriskComment is set (has been assigned a value) and false otherwise */
  public boolean isSetSingleAsteriskComment() {
    return __isset_bit_vector.get(__SINGLEASTERISKCOMMENT_ISSET_ID);
  }

  public void setSingleAsteriskCommentIsSet(boolean value) {
    __isset_bit_vector.set(__SINGLEASTERISKCOMMENT_ISSET_ID, value);
  }

  public long getDocStringComment() {
    return this.docStringComment;
  }

  public Request setDocStringComment(long docStringComment) {
    this.docStringComment = docStringComment;
    setDocStringCommentIsSet(true);

    return this;
  }

  public void unsetDocStringComment() {
  __isset_bit_vector.clear(__DOCSTRINGCOMMENT_ISSET_ID);
  }

  /** Returns true if field docStringComment is set (has been assigned a value) and false otherwise */
  public boolean isSetDocStringComment() {
    return __isset_bit_vector.get(__DOCSTRINGCOMMENT_ISSET_ID);
  }

  public void setDocStringCommentIsSet(boolean value) {
    __isset_bit_vector.set(__DOCSTRINGCOMMENT_ISSET_ID, value);
  }

  public Recursive getRecRequest() {
    return this.recRequest;
  }

  public Request setRecRequest(Recursive recRequest) {
    this.recRequest = recRequest;
    
    return this;
  }

  public void unsetRecRequest() {
    this.recRequest = null;
  }

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

  public void setRecRequestIsSet(boolean value) {
    if (!value) {
      this.recRequest = null;
    }
  }

  public String getRequiredField() {
    return this.requiredField;
  }

  public Request setRequiredField(String requiredField) {
    this.requiredField = requiredField;
    
    return this;
  }

  public void unsetRequiredField() {
    this.requiredField = null;
  }

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

  public void setRequiredFieldIsSet(boolean value) {
    if (!value) {
      this.requiredField = null;
    }
  }

  public long getConstructionRequiredField() {
    return this.constructionRequiredField;
  }

  public Request setConstructionRequiredField(long constructionRequiredField) {
    this.constructionRequiredField = constructionRequiredField;
    setConstructionRequiredFieldIsSet(true);

    return this;
  }

  public void unsetConstructionRequiredField() {
  __isset_bit_vector.clear(__CONSTRUCTIONREQUIREDFIELD_ISSET_ID);
  }

  /** Returns true if field constructionRequiredField is set (has been assigned a value) and false otherwise */
  public boolean isSetConstructionRequiredField() {
    return __isset_bit_vector.get(__CONSTRUCTIONREQUIREDFIELD_ISSET_ID);
  }

  public void setConstructionRequiredFieldIsSet(boolean value) {
    __isset_bit_vector.set(__CONSTRUCTIONREQUIREDFIELD_ISSET_ID, value);
  }

  public byte getAnInt8() {
    return this.anInt8;
  }

  public Request setAnInt8(byte anInt8) {
    this.anInt8 = anInt8;
    setAnInt8IsSet(true);

    return this;
  }

  public void unsetAnInt8() {
  __isset_bit_vector.clear(__ANINT8_ISSET_ID);
  }

  /** Returns true if field anInt8 is set (has been assigned a value) and false otherwise */
  public boolean isSetAnInt8() {
    return __isset_bit_vector.get(__ANINT8_ISSET_ID);
  }

  public void setAnInt8IsSet(boolean value) {
    __isset_bit_vector.set(__ANINT8_ISSET_ID, value);
  }

  public byte[] getABinaryField() {
    setABinaryField(TBaseHelper.rightSize(aBinaryField));
    return aBinaryField.array();
  }

  public ByteBuffer BufferForABinaryField() {
    return aBinaryField;
  }

  public Request setABinaryField(byte[] aBinaryField) {
    setABinaryField(ByteBuffer.wrap(aBinaryField));
    return this;
  }

  public Request setABinaryField(ByteBuffer aBinaryField) {
    this.aBinaryField = aBinaryField;
    
    return this;
  }

  public void unsetABinaryField() {
    this.aBinaryField = null;
  }

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

  public void setABinaryFieldIsSet(boolean value) {
    if (!value) {
      this.aBinaryField = null;
    }
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case A_LIST:
      if (value == null) {
        unsetAList();
      } else {
        setAList((List<String>)value);
      }
      break;
    case A_SET:
      if (value == null) {
        unsetASet();
      } else {
        setASet((Set<Integer>)value);
      }
      break;
    case A_MAP:
      if (value == null) {
        unsetAMap();
      } else {
        setAMap((Map<Long,Long>)value);
      }
      break;
    case A_REQUEST:
      if (value == null) {
        unsetARequest();
      } else {
        setARequest((Request)value);
      }
      break;
    case SUB_REQUESTS:
      if (value == null) {
        unsetSubRequests();
      } else {
        setSubRequests((List<Request>)value);
      }
      break;
    case _DEFAULT:
      if (value == null) {
        unset_default();
      } else {
        set_default((String)value);
      }
      break;
    case NO_COMMENT:
      if (value == null) {
        unsetNoComment();
      } else {
        setNoComment((Long)value);
      }
      break;
    case DOUBLE_SLASH_COMMENT:
      if (value == null) {
        unsetDoubleSlashComment();
      } else {
        setDoubleSlashComment((Long)value);
      }
      break;
    case HASHTAG_COMMENT:
      if (value == null) {
        unsetHashtagComment();
      } else {
        setHashtagComment((Long)value);
      }
      break;
    case SINGLE_ASTERISK_COMMENT:
      if (value == null) {
        unsetSingleAsteriskComment();
      } else {
        setSingleAsteriskComment((Long)value);
      }
      break;
    case DOC_STRING_COMMENT:
      if (value == null) {
        unsetDocStringComment();
      } else {
        setDocStringComment((Long)value);
      }
      break;
    case REC_REQUEST:
      if (value == null) {
        unsetRecRequest();
      } else {
        setRecRequest((Recursive)value);
      }
      break;
    case REQUIRED_FIELD:
      if (value == null) {
        unsetRequiredField();
      } else {
        setRequiredField((String)value);
      }
      break;
    case CONSTRUCTION_REQUIRED_FIELD:
      if (value == null) {
        unsetConstructionRequiredField();
      } else {
        setConstructionRequiredField((Long)value);
      }
      break;
    case AN_INT8:
      if (value == null) {
        unsetAnInt8();
      } else {
        setAnInt8((Byte)value);
      }
      break;
    case A_BINARY_FIELD:
      if (value == null) {
        unsetABinaryField();
      } else {
        setABinaryField((ByteBuffer)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case A_LIST:
      return getAList();
    case A_SET:
      return getASet();
    case A_MAP:
      return getAMap();
    case A_REQUEST:
      return getARequest();
    case SUB_REQUESTS:
      return getSubRequests();
    case _DEFAULT:
      return get_default();
    case NO_COMMENT:
      return Long.valueOf(getNoComment());
    case DOUBLE_SLASH_COMMENT:
      return Long.valueOf(getDoubleSlashComment());
    case HASHTAG_COMMENT:
      return Long.valueOf(getHashtagComment());
    case SINGLE_ASTERISK_COMMENT:
      return Long.valueOf(getSingleAsteriskComment());
    case DOC_STRING_COMMENT:
      return Long.valueOf(getDocStringComment());
    case REC_REQUEST:
      return getRecRequest();
    case REQUIRED_FIELD:
      return getRequiredField();
    case CONSTRUCTION_REQUIRED_FIELD:
      return Long.valueOf(getConstructionRequiredField());
    case AN_INT8:
      return Byte.valueOf(getAnInt8());
    case A_BINARY_FIELD:
      return getABinaryField();
    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case A_LIST:
      return isSetAList();
    case A_SET:
      return isSetASet();
    case A_MAP:
      return isSetAMap();
    case A_REQUEST:
      return isSetARequest();
    case SUB_REQUESTS:
      return isSetSubRequests();
    case _DEFAULT:
      return isSet_default();
    case NO_COMMENT:
      return isSetNoComment();
    case DOUBLE_SLASH_COMMENT:
      return isSetDoubleSlashComment();
    case HASHTAG_COMMENT:
      return isSetHashtagComment();
    case SINGLE_ASTERISK_COMMENT:
      return isSetSingleAsteriskComment();
    case DOC_STRING_COMMENT:
      return isSetDocStringComment();
    case REC_REQUEST:
      return isSetRecRequest();
    case REQUIRED_FIELD:
      return isSetRequiredField();
    case CONSTRUCTION_REQUIRED_FIELD:
      return isSetConstructionRequiredField();
    case AN_INT8:
      return isSetAnInt8();
    case A_BINARY_FIELD:
      return isSetABinaryField();
    }
    throw new IllegalStateException();
  }

  @java.lang.Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof Request)
      return this.equals((Request)that);
    return false;
  }

  public boolean equals(Request that) {
    return equalsWithoutPassthrough(that) && passthroughFieldsAreEqual(that);
  }

  private boolean equalsWithoutPassthrough(Request that) {
    if (that == null)
      return false;
    boolean this_present_aList = true && this.isSetAList();
    boolean that_present_aList = true && that.isSetAList();
    if (this_present_aList || that_present_aList) {
      if (!(this_present_aList && that_present_aList))
        return false;
      if (!this.aList.equals(that.aList))
        return false;
    }
    boolean this_present_aSet = true && this.isSetASet();
    boolean that_present_aSet = true && that.isSetASet();
    if (this_present_aSet || that_present_aSet) {
      if (!(this_present_aSet && that_present_aSet))
        return false;
      if (!this.aSet.equals(that.aSet))
        return false;
    }
    boolean this_present_aMap = true && this.isSetAMap();
    boolean that_present_aMap = true && that.isSetAMap();
    if (this_present_aMap || that_present_aMap) {
      if (!(this_present_aMap && that_present_aMap))
        return false;
      if (!this.aMap.equals(that.aMap))
        return false;
    }
    boolean this_present_aRequest = true && this.isSetARequest();
    boolean that_present_aRequest = true && that.isSetARequest();
    if (this_present_aRequest || that_present_aRequest) {
      if (!(this_present_aRequest && that_present_aRequest))
        return false;
      if (!this.aRequest.equals(that.aRequest))
        return false;
    }
    boolean this_present_subRequests = true && this.isSetSubRequests();
    boolean that_present_subRequests = true && that.isSetSubRequests();
    if (this_present_subRequests || that_present_subRequests) {
      if (!(this_present_subRequests && that_present_subRequests))
        return false;
      if (!this.subRequests.equals(that.subRequests))
        return false;
    }
    boolean this_present__default = true && this.isSet_default();
    boolean that_present__default = true && that.isSet_default();
    if (this_present__default || that_present__default) {
      if (!(this_present__default && that_present__default))
        return false;
      if (!this._default.equals(that._default))
        return false;
    }
    boolean this_present_noComment = true && this.isSetNoComment();
    boolean that_present_noComment = true && that.isSetNoComment();
    if (this_present_noComment || that_present_noComment) {
      if (!(this_present_noComment && that_present_noComment))
        return false;
      if (this.noComment != that.noComment)
        return false;
    }
    boolean this_present_doubleSlashComment = true && this.isSetDoubleSlashComment();
    boolean that_present_doubleSlashComment = true && that.isSetDoubleSlashComment();
    if (this_present_doubleSlashComment || that_present_doubleSlashComment) {
      if (!(this_present_doubleSlashComment && that_present_doubleSlashComment))
        return false;
      if (this.doubleSlashComment != that.doubleSlashComment)
        return false;
    }
    boolean this_present_hashtagComment = true && this.isSetHashtagComment();
    boolean that_present_hashtagComment = true && that.isSetHashtagComment();
    if (this_present_hashtagComment || that_present_hashtagComment) {
      if (!(this_present_hashtagComment && that_present_hashtagComment))
        return false;
      if (this.hashtagComment != that.hashtagComment)
        return false;
    }
    boolean this_present_singleAsteriskComment = true && this.isSetSingleAsteriskComment();
    boolean that_present_singleAsteriskComment = true && that.isSetSingleAsteriskComment();
    if (this_present_singleAsteriskComment || that_present_singleAsteriskComment) {
      if (!(this_present_singleAsteriskComment && that_present_singleAsteriskComment))
        return false;
      if (this.singleAsteriskComment != that.singleAsteriskComment)
        return false;
    }
    boolean this_present_docStringComment = true && this.isSetDocStringComment();
    boolean that_present_docStringComment = true && that.isSetDocStringComment();
    if (this_present_docStringComment || that_present_docStringComment) {
      if (!(this_present_docStringComment && that_present_docStringComment))
        return false;
      if (this.docStringComment != that.docStringComment)
        return false;
    }
    boolean this_present_recRequest = true && this.isSetRecRequest();
    boolean that_present_recRequest = true && that.isSetRecRequest();
    if (this_present_recRequest || that_present_recRequest) {
      if (!(this_present_recRequest && that_present_recRequest))
        return false;
      if (!this.recRequest.equals(that.recRequest))
        return false;
    }
    boolean this_present_requiredField = true && this.isSetRequiredField();
    boolean that_present_requiredField = true && that.isSetRequiredField();
    if (this_present_requiredField || that_present_requiredField) {
      if (!(this_present_requiredField && that_present_requiredField))
        return false;
      if (!this.requiredField.equals(that.requiredField))
        return false;
    }
    boolean this_present_constructionRequiredField = true && this.isSetConstructionRequiredField();
    boolean that_present_constructionRequiredField = true && that.isSetConstructionRequiredField();
    if (this_present_constructionRequiredField || that_present_constructionRequiredField) {
      if (!(this_present_constructionRequiredField && that_present_constructionRequiredField))
        return false;
      if (this.constructionRequiredField != that.constructionRequiredField)
        return false;
    }
    boolean this_present_anInt8 = true && this.isSetAnInt8();
    boolean that_present_anInt8 = true && that.isSetAnInt8();
    if (this_present_anInt8 || that_present_anInt8) {
      if (!(this_present_anInt8 && that_present_anInt8))
        return false;
      if (this.anInt8 != that.anInt8)
        return false;
    }
    boolean this_present_aBinaryField = true && this.isSetABinaryField();
    boolean that_present_aBinaryField = true && that.isSetABinaryField();
    if (this_present_aBinaryField || that_present_aBinaryField) {
      if (!(this_present_aBinaryField && that_present_aBinaryField))
        return false;
      if (!this.aBinaryField.equals(that.aBinaryField))
        return false;
    }
    return true;
  }

  private boolean passthroughFieldsAreEqual(Request that) {
    if (that == null)
      return false;
    if (this.passThroughFields == null && that.passThroughFields != null)
      return false;
    if (this.passThroughFields == that.passThroughFields
        || this.passThroughFields.equals(that.passThroughFields))
      return true;
    return false;
  }

  @java.lang.Override
  public int hashCode() {
    int hashCode = 1;
    if (isSetAList()) {
      hashCode = 31 * hashCode + aList.hashCode();
    }
    if (isSetASet()) {
      hashCode = 31 * hashCode + aSet.hashCode();
    }
    if (isSetAMap()) {
      hashCode = 31 * hashCode + aMap.hashCode();
    }
    if (isSetARequest()) {
      hashCode = 31 * hashCode + aRequest.hashCode();
    }
    if (isSetSubRequests()) {
      hashCode = 31 * hashCode + subRequests.hashCode();
    }
    if (isSet_default()) {
      hashCode = 31 * hashCode + _default.hashCode();
    }
    if (isSetNoComment()) {
      hashCode = 31 * hashCode + ((Long)noComment).hashCode();
    }
    if (isSetDoubleSlashComment()) {
      hashCode = 31 * hashCode + ((Long)doubleSlashComment).hashCode();
    }
    if (isSetHashtagComment()) {
      hashCode = 31 * hashCode + ((Long)hashtagComment).hashCode();
    }
    if (isSetSingleAsteriskComment()) {
      hashCode = 31 * hashCode + ((Long)singleAsteriskComment).hashCode();
    }
    if (isSetDocStringComment()) {
      hashCode = 31 * hashCode + ((Long)docStringComment).hashCode();
    }
    if (isSetRecRequest()) {
      hashCode = 31 * hashCode + recRequest.hashCode();
    }
    if (isSetRequiredField()) {
      hashCode = 31 * hashCode + requiredField.hashCode();
    }
    if (isSetConstructionRequiredField()) {
      hashCode = 31 * hashCode + ((Long)constructionRequiredField).hashCode();
    }
    if (isSetAnInt8()) {
      hashCode = 31 * hashCode + ((Byte)anInt8).hashCode();
    }
    if (isSetABinaryField()) {
      hashCode = 31 * hashCode + aBinaryField.hashCode();
    }
    return hashCode;
  }

  public int compareTo(Request other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    Request typedOther = (Request)other;

    lastComparison = Boolean.valueOf(isSetAList()).compareTo(typedOther.isSetAList());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAList()) {
      lastComparison = TBaseHelper.compareTo(this.aList, typedOther.aList);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetASet()).compareTo(typedOther.isSetASet());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetASet()) {
      lastComparison = TBaseHelper.compareTo(this.aSet, typedOther.aSet);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetAMap()).compareTo(typedOther.isSetAMap());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAMap()) {
      lastComparison = TBaseHelper.compareTo(this.aMap, typedOther.aMap);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetARequest()).compareTo(typedOther.isSetARequest());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetARequest()) {
      lastComparison = TBaseHelper.compareTo(this.aRequest, typedOther.aRequest);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetSubRequests()).compareTo(typedOther.isSetSubRequests());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSubRequests()) {
      lastComparison = TBaseHelper.compareTo(this.subRequests, typedOther.subRequests);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSet_default()).compareTo(typedOther.isSet_default());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSet_default()) {
      lastComparison = TBaseHelper.compareTo(this._default, typedOther._default);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNoComment()).compareTo(typedOther.isSetNoComment());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNoComment()) {
      lastComparison = TBaseHelper.compareTo(this.noComment, typedOther.noComment);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDoubleSlashComment()).compareTo(typedOther.isSetDoubleSlashComment());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDoubleSlashComment()) {
      lastComparison = TBaseHelper.compareTo(this.doubleSlashComment, typedOther.doubleSlashComment);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetHashtagComment()).compareTo(typedOther.isSetHashtagComment());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHashtagComment()) {
      lastComparison = TBaseHelper.compareTo(this.hashtagComment, typedOther.hashtagComment);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetSingleAsteriskComment()).compareTo(typedOther.isSetSingleAsteriskComment());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSingleAsteriskComment()) {
      lastComparison = TBaseHelper.compareTo(this.singleAsteriskComment, typedOther.singleAsteriskComment);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDocStringComment()).compareTo(typedOther.isSetDocStringComment());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDocStringComment()) {
      lastComparison = TBaseHelper.compareTo(this.docStringComment, typedOther.docStringComment);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRecRequest()).compareTo(typedOther.isSetRecRequest());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRecRequest()) {
      lastComparison = TBaseHelper.compareTo(this.recRequest, typedOther.recRequest);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRequiredField()).compareTo(typedOther.isSetRequiredField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRequiredField()) {
      lastComparison = TBaseHelper.compareTo(this.requiredField, typedOther.requiredField);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetConstructionRequiredField()).compareTo(typedOther.isSetConstructionRequiredField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetConstructionRequiredField()) {
      lastComparison = TBaseHelper.compareTo(this.constructionRequiredField, typedOther.constructionRequiredField);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetAnInt8()).compareTo(typedOther.isSetAnInt8());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAnInt8()) {
      lastComparison = TBaseHelper.compareTo(this.anInt8, typedOther.anInt8);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetABinaryField()).compareTo(typedOther.isSetABinaryField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetABinaryField()) {
      lastComparison = TBaseHelper.compareTo(this.aBinaryField, typedOther.aBinaryField);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }


  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) {
        break;
      }
      switch (field.id) {
        case 1: // A_LIST
          TProtocols.validateFieldType(TType.LIST, field.type, "aList");
          {
            TList _list0 = iprot.readListBegin();
            int _list0_size = _list0.size;
            this.aList = new ArrayList<String>(_list0_size);
            for (int _i1 = 0; _i1 < _list0.size; ++_i1)
            {
              String _elem2;
              _elem2 = iprot.readString();
              this.aList.add(_elem2);
            }
            iprot.readListEnd();
            }
          break;
        case 2: // A_SET
          TProtocols.validateFieldType(TType.SET, field.type, "aSet");
          {
            TSet _set3 = iprot.readSetBegin();
            int _set3_size = (int) ((float) _set3.size / 0.75F + 1.0F);
            this.aSet = new HashSet<Integer>(_set3_size);
            for (int _i4 = 0; _i4 < _set3.size; ++_i4)
            {
              int _elem5;
              _elem5 = iprot.readI32();
              this.aSet.add(_elem5);
            }
            iprot.readSetEnd();
            }
          break;
        case 3: // A_MAP
          TProtocols.validateFieldType(TType.MAP, field.type, "aMap");
          {
            TMap _map6 = iprot.readMapBegin();
            int _map6_size = (int) ((float) _map6.size / 0.75F + 1.0F);
            this.aMap = new HashMap<Long,Long>(_map6_size);
            for (int _i7 = 0; _i7 < _map6.size; ++_i7)
            {
              long _key8;
              long _val9;
              _key8 = iprot.readI64();
              _val9 = iprot.readI64();
              this.aMap.put(_key8, _val9);
            }
            iprot.readMapEnd();
            }
          break;
        case 4: // A_REQUEST
          TProtocols.validateFieldType(TType.STRUCT, field.type, "aRequest");
          this.aRequest = new Request();
            this.aRequest.read(iprot);
          break;
        case 5: // SUB_REQUESTS
          TProtocols.validateFieldType(TType.LIST, field.type, "subRequests");
          {
            TList _list10 = iprot.readListBegin();
            int _list10_size = _list10.size;
            this.subRequests = new ArrayList<Request>(_list10_size);
            for (int _i11 = 0; _i11 < _list10.size; ++_i11)
            {
              Request _elem12;
              _elem12 = new Request();
              _elem12.read(iprot);
              this.subRequests.add(_elem12);
            }
            iprot.readListEnd();
            }
          break;
        case 6: // _DEFAULT
          TProtocols.validateFieldType(TType.STRING, field.type, "_default");
          this._default = iprot.readString();
          break;
        case 7: // NO_COMMENT
          TProtocols.validateFieldType(TType.I64, field.type, "noComment");
          this.noComment = iprot.readI64();
          setNoCommentIsSet(true);
          break;
        case 8: // DOUBLE_SLASH_COMMENT
          TProtocols.validateFieldType(TType.I64, field.type, "doubleSlashComment");
          this.doubleSlashComment = iprot.readI64();
          setDoubleSlashCommentIsSet(true);
          break;
        case 9: // HASHTAG_COMMENT
          TProtocols.validateFieldType(TType.I64, field.type, "hashtagComment");
          this.hashtagComment = iprot.readI64();
          setHashtagCommentIsSet(true);
          break;
        case 10: // SINGLE_ASTERISK_COMMENT
          TProtocols.validateFieldType(TType.I64, field.type, "singleAsteriskComment");
          this.singleAsteriskComment = iprot.readI64();
          setSingleAsteriskCommentIsSet(true);
          break;
        case 11: // DOC_STRING_COMMENT
          TProtocols.validateFieldType(TType.I64, field.type, "docStringComment");
          this.docStringComment = iprot.readI64();
          setDocStringCommentIsSet(true);
          break;
        case 12: // REC_REQUEST
          TProtocols.validateFieldType(TType.STRUCT, field.type, "recRequest");
          this.recRequest = new Recursive();
            this.recRequest.read(iprot);
          break;
        case 13: // REQUIRED_FIELD
          TProtocols.validateFieldType(TType.STRING, field.type, "requiredField");
          this.requiredField = iprot.readString();
          break;
        case 14: // CONSTRUCTION_REQUIRED_FIELD
          TProtocols.validateFieldType(TType.I64, field.type, "constructionRequiredField");
          this.constructionRequiredField = iprot.readI64();
          setConstructionRequiredFieldIsSet(true);
          break;
        case 15: // AN_INT8
          TProtocols.validateFieldType(TType.BYTE, field.type, "anInt8");
          this.anInt8 = iprot.readByte();
          setAnInt8IsSet(true);
          break;
        case 16: // A_BINARY_FIELD
          TProtocols.validateFieldType(TType.STRING, field.type, "aBinaryField");
          this.aBinaryField = iprot.readBinary();
          break;
        default:
          if (this.passThroughFields == null) {
            this.passThroughFields = new HashMap<Short, TFieldBlob>();
          }
          this.passThroughFields.put(field.id, TFieldBlob.extractBlob(field, iprot));
      }
      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);
    if (this.aList != null) {
      oprot.writeFieldBegin(A_LIST_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.aList.size()));
        for (String _iter13 : this.aList)
        {
          oprot.writeString(_iter13);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.aSet != null) {
      oprot.writeFieldBegin(A_SET_FIELD_DESC);
      {
        oprot.writeSetBegin(new TSet(TType.I32, this.aSet.size()));
        for (int _iter14 : this.aSet)
        {
          oprot.writeI32(_iter14);
        }
        oprot.writeSetEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.aMap != null) {
      oprot.writeFieldBegin(A_MAP_FIELD_DESC);
      {
        oprot.writeMapBegin(new TMap(TType.I64, TType.I64, this.aMap.size()));
        for (Map.Entry<Long, Long> _iter15 : this.aMap.entrySet())
        {
          oprot.writeI64(_iter15.getKey());
          oprot.writeI64(_iter15.getValue());
        }
        oprot.writeMapEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.aRequest != null) {
      if (isSetARequest()) {
        oprot.writeFieldBegin(A_REQUEST_FIELD_DESC);
        this.aRequest.write(oprot);
        oprot.writeFieldEnd();
      }
    }
    if (this.subRequests != null) {
      oprot.writeFieldBegin(SUB_REQUESTS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.subRequests.size()));
        for (Request _iter16 : this.subRequests)
        {
          _iter16.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this._default != null) {
      oprot.writeFieldBegin(_DEFAULT_FIELD_DESC);
      oprot.writeString(this._default);
      oprot.writeFieldEnd();
    }
    if (isSetNoComment()) {
      oprot.writeFieldBegin(NO_COMMENT_FIELD_DESC);
      oprot.writeI64(this.noComment);
      oprot.writeFieldEnd();
    }
    if (isSetDoubleSlashComment()) {
      oprot.writeFieldBegin(DOUBLE_SLASH_COMMENT_FIELD_DESC);
      oprot.writeI64(this.doubleSlashComment);
      oprot.writeFieldEnd();
    }
    if (isSetHashtagComment()) {
      oprot.writeFieldBegin(HASHTAG_COMMENT_FIELD_DESC);
      oprot.writeI64(this.hashtagComment);
      oprot.writeFieldEnd();
    }
    if (isSetSingleAsteriskComment()) {
      oprot.writeFieldBegin(SINGLE_ASTERISK_COMMENT_FIELD_DESC);
      oprot.writeI64(this.singleAsteriskComment);
      oprot.writeFieldEnd();
    }
    if (isSetDocStringComment()) {
      oprot.writeFieldBegin(DOC_STRING_COMMENT_FIELD_DESC);
      oprot.writeI64(this.docStringComment);
      oprot.writeFieldEnd();
    }
    if (this.recRequest != null) {
      if (isSetRecRequest()) {
        oprot.writeFieldBegin(REC_REQUEST_FIELD_DESC);
        this.recRequest.write(oprot);
        oprot.writeFieldEnd();
      }
    }
    if (this.requiredField != null) {
      oprot.writeFieldBegin(REQUIRED_FIELD_FIELD_DESC);
      oprot.writeString(this.requiredField);
      oprot.writeFieldEnd();
    }
    if (isSetConstructionRequiredField()) {
      oprot.writeFieldBegin(CONSTRUCTION_REQUIRED_FIELD_FIELD_DESC);
      oprot.writeI64(this.constructionRequiredField);
      oprot.writeFieldEnd();
    }
    if (isSetAnInt8()) {
      oprot.writeFieldBegin(AN_INT8_FIELD_DESC);
      oprot.writeByte(this.anInt8);
      oprot.writeFieldEnd();
    }
    if (this.aBinaryField != null) {
      if (isSetABinaryField()) {
        oprot.writeFieldBegin(A_BINARY_FIELD_FIELD_DESC);
        oprot.writeBinary(this.aBinaryField);
        oprot.writeFieldEnd();
      }
    }
    if (this.passThroughFields != null) {
      for (TFieldBlob field : this.passThroughFields.values()) {
        field.write(oprot);
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @java.lang.Override
  public String toString() {
    StringBuilder sb = new StringBuilder("Request(");
    boolean first = true;
    sb.append("aList:");
    if (this.aList == null) {
      sb.append("null");
    } else {
      sb.append(this.aList);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("aSet:");
    if (this.aSet == null) {
      sb.append("null");
    } else {
      sb.append(this.aSet);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("aMap:");
    if (this.aMap == null) {
      sb.append("null");
    } else {
      sb.append(this.aMap);
    }
    first = false;
    if (isSetARequest()) {
      if (!first) sb.append(", ");
      sb.append("aRequest:");
      if (this.aRequest == null) {
        sb.append("null");
      } else {
        sb.append(this.aRequest);
      }
      first = false;
      }
    if (!first) sb.append(", ");
    sb.append("subRequests:");
    if (this.subRequests == null) {
      sb.append("null");
    } else {
      sb.append(this.subRequests);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("_default:");
    if (this._default == null) {
      sb.append("null");
    } else {
      sb.append(this._default);
    }
    first = false;
    if (isSetNoComment()) {
      if (!first) sb.append(", ");
      sb.append("noComment:");
      sb.append(this.noComment);
      first = false;
      }
    if (isSetDoubleSlashComment()) {
      if (!first) sb.append(", ");
      sb.append("doubleSlashComment:");
      sb.append(this.doubleSlashComment);
      first = false;
      }
    if (isSetHashtagComment()) {
      if (!first) sb.append(", ");
      sb.append("hashtagComment:");
      sb.append(this.hashtagComment);
      first = false;
      }
    if (isSetSingleAsteriskComment()) {
      if (!first) sb.append(", ");
      sb.append("singleAsteriskComment:");
      sb.append(this.singleAsteriskComment);
      first = false;
      }
    if (isSetDocStringComment()) {
      if (!first) sb.append(", ");
      sb.append("docStringComment:");
      sb.append(this.docStringComment);
      first = false;
      }
    if (isSetRecRequest()) {
      if (!first) sb.append(", ");
      sb.append("recRequest:");
      if (this.recRequest == null) {
        sb.append("null");
      } else {
        sb.append(this.recRequest);
      }
      first = false;
      }
    if (!first) sb.append(", ");
    sb.append("requiredField:");
    if (this.requiredField == null) {
      sb.append("null");
    } else {
      sb.append(this.requiredField);
    }
    first = false;
    if (isSetConstructionRequiredField()) {
      if (!first) sb.append(", ");
      sb.append("constructionRequiredField:");
      sb.append(this.constructionRequiredField);
      first = false;
      }
    if (isSetAnInt8()) {
      if (!first) sb.append(", ");
      sb.append("anInt8:");
      sb.append(this.anInt8);
      first = false;
      }
    if (isSetABinaryField()) {
      if (!first) sb.append(", ");
      sb.append("aBinaryField:");
      if (this.aBinaryField == null) {
        sb.append("null");
      } else {
        TBaseHelper.toString(this.aBinaryField, sb);
      }
      first = false;
      }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
    if (requiredField == null) {
      throw new TProtocolException("Required field 'requiredField' was not present! Struct: " + toString());
    }
  }
}

