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

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 Foo implements TBase, java.io.Serializable, Cloneable, Comparable<Foo> {
  private static final TStruct STRUCT_DESC = new TStruct("Foo");
  private static final TField INT_FIELD_FIELD_DESC = new TField("intField", TType.I32, (short)1);
  private static final TField OPTIONAL_INT_FIELD_FIELD_DESC = new TField("optionalIntField", TType.I32, (short)2);
  private static final TField INT_FIELD_WITH_DEFAULT_FIELD_DESC = new TField("intFieldWithDefault", TType.I32, (short)3);
  private static final TField SET_FIELD_FIELD_DESC = new TField("setField", TType.SET, (short)4);
  private static final TField OPTIONAL_SET_FIELD_FIELD_DESC = new TField("optionalSetField", TType.SET, (short)5);
  private static final TField MAP_FIELD_FIELD_DESC = new TField("mapField", TType.MAP, (short)6);
  private static final TField OPTIONAL_MAP_FIELD_FIELD_DESC = new TField("optionalMapField", TType.MAP, (short)7);
  private static final TField BINARY_FIELD_FIELD_DESC = new TField("binaryField", TType.STRING, (short)8);
  private static final TField LONG_FIELD_FIELD_DESC = new TField("longField", TType.I64, (short)9);
  private static final TField ADAPTED_LONG_FIELD_FIELD_DESC = new TField("adaptedLongField", TType.I64, (short)10);
  private static final TField DOUBLE_ADAPTED_FIELD_FIELD_DESC = new TField("doubleAdaptedField", TType.I64, (short)11);

  public int intField;
  public int optionalIntField;
  public int intFieldWithDefault;
  public Set<String> setField;
  public Set<String> optionalSetField;
  public Map<String,List<String>> mapField;
  public Map<String,List<String>> optionalMapField;
  public byte[] binaryField;
  public long longField;
  public long adaptedLongField;
  public long doubleAdaptedField;
  public static final int INTFIELD = 1;
  public static final int OPTIONALINTFIELD = 2;
  public static final int INTFIELDWITHDEFAULT = 3;
  public static final int SETFIELD = 4;
  public static final int OPTIONALSETFIELD = 5;
  public static final int MAPFIELD = 6;
  public static final int OPTIONALMAPFIELD = 7;
  public static final int BINARYFIELD = 8;
  public static final int LONGFIELD = 9;
  public static final int ADAPTEDLONGFIELD = 10;
  public static final int DOUBLEADAPTEDFIELD = 11;

  // isset id assignments
  private static final int __INTFIELD_ISSET_ID = 0;
  private static final int __OPTIONALINTFIELD_ISSET_ID = 1;
  private static final int __INTFIELDWITHDEFAULT_ISSET_ID = 2;
  private static final int __LONGFIELD_ISSET_ID = 3;
  private static final int __ADAPTEDLONGFIELD_ISSET_ID = 4;
  private static final int __DOUBLEADAPTEDFIELD_ISSET_ID = 5;
  private BitSet __isset_bit_vector = new BitSet(6);

  public static final Map<Integer, FieldMetaData> metaDataMap;

  static {
    Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
    tmpMetaDataMap.put(INTFIELD, new FieldMetaData("intField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(OPTIONALINTFIELD, new FieldMetaData("optionalIntField", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(INTFIELDWITHDEFAULT, new FieldMetaData("intFieldWithDefault", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(SETFIELD, new FieldMetaData("setField", TFieldRequirementType.DEFAULT, 
        new SetMetaData(TType.SET, 
            new FieldValueMetaData(TType.STRING))));
    tmpMetaDataMap.put(OPTIONALSETFIELD, new FieldMetaData("optionalSetField", TFieldRequirementType.OPTIONAL, 
        new SetMetaData(TType.SET, 
            new FieldValueMetaData(TType.STRING))));
    tmpMetaDataMap.put(MAPFIELD, new FieldMetaData("mapField", TFieldRequirementType.DEFAULT, 
        new MapMetaData(TType.MAP, 
            new FieldValueMetaData(TType.STRING), 
            new ListMetaData(TType.LIST, 
                new FieldValueMetaData(TType.STRING)))));
    tmpMetaDataMap.put(OPTIONALMAPFIELD, new FieldMetaData("optionalMapField", TFieldRequirementType.OPTIONAL, 
        new MapMetaData(TType.MAP, 
            new FieldValueMetaData(TType.STRING), 
            new ListMetaData(TType.LIST, 
                new FieldValueMetaData(TType.STRING)))));
    tmpMetaDataMap.put(BINARYFIELD, new FieldMetaData("binaryField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    tmpMetaDataMap.put(LONGFIELD, new FieldMetaData("longField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(ADAPTEDLONGFIELD, new FieldMetaData("adaptedLongField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(DOUBLEADAPTEDFIELD, new FieldMetaData("doubleAdaptedField", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

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

  public Foo() {
    this.intFieldWithDefault = 13;

  }

  public Foo(
      int intField,
      int intFieldWithDefault,
      Set<String> setField,
      Map<String,List<String>> mapField,
      byte[] binaryField,
      long longField,
      long adaptedLongField,
      long doubleAdaptedField) {
    this();
    this.intField = intField;
    setIntFieldIsSet(true);
    this.intFieldWithDefault = intFieldWithDefault;
    setIntFieldWithDefaultIsSet(true);
    this.setField = setField;
    this.mapField = mapField;
    this.binaryField = binaryField;
    this.longField = longField;
    setLongFieldIsSet(true);
    this.adaptedLongField = adaptedLongField;
    setAdaptedLongFieldIsSet(true);
    this.doubleAdaptedField = doubleAdaptedField;
    setDoubleAdaptedFieldIsSet(true);
  }

  public Foo(
      int intField,
      int optionalIntField,
      int intFieldWithDefault,
      Set<String> setField,
      Set<String> optionalSetField,
      Map<String,List<String>> mapField,
      Map<String,List<String>> optionalMapField,
      byte[] binaryField,
      long longField,
      long adaptedLongField,
      long doubleAdaptedField) {
    this();
    this.intField = intField;
    setIntFieldIsSet(true);
    this.optionalIntField = optionalIntField;
    setOptionalIntFieldIsSet(true);
    this.intFieldWithDefault = intFieldWithDefault;
    setIntFieldWithDefaultIsSet(true);
    this.setField = setField;
    this.optionalSetField = optionalSetField;
    this.mapField = mapField;
    this.optionalMapField = optionalMapField;
    this.binaryField = binaryField;
    this.longField = longField;
    setLongFieldIsSet(true);
    this.adaptedLongField = adaptedLongField;
    setAdaptedLongFieldIsSet(true);
    this.doubleAdaptedField = doubleAdaptedField;
    setDoubleAdaptedFieldIsSet(true);
  }

  public static class Builder {
    private int intField;
    private int optionalIntField;
    private int intFieldWithDefault;
    private Set<String> setField;
    private Set<String> optionalSetField;
    private Map<String,List<String>> mapField;
    private Map<String,List<String>> optionalMapField;
    private byte[] binaryField;
    private long longField;
    private long adaptedLongField;
    private long doubleAdaptedField;

    BitSet __optional_isset = new BitSet(6);

    public Builder() {
    }

    public Builder setIntField(final int intField) {
      this.intField = intField;
      __optional_isset.set(__INTFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setOptionalIntField(final int optionalIntField) {
      this.optionalIntField = optionalIntField;
      __optional_isset.set(__OPTIONALINTFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setIntFieldWithDefault(final int intFieldWithDefault) {
      this.intFieldWithDefault = intFieldWithDefault;
      __optional_isset.set(__INTFIELDWITHDEFAULT_ISSET_ID, true);
      return this;
    }

    public Builder setSetField(final Set<String> setField) {
      this.setField = setField;
      return this;
    }

    public Builder setOptionalSetField(final Set<String> optionalSetField) {
      this.optionalSetField = optionalSetField;
      return this;
    }

    public Builder setMapField(final Map<String,List<String>> mapField) {
      this.mapField = mapField;
      return this;
    }

    public Builder setOptionalMapField(final Map<String,List<String>> optionalMapField) {
      this.optionalMapField = optionalMapField;
      return this;
    }

    public Builder setBinaryField(final byte[] binaryField) {
      this.binaryField = binaryField;
      return this;
    }

    public Builder setLongField(final long longField) {
      this.longField = longField;
      __optional_isset.set(__LONGFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setAdaptedLongField(final long adaptedLongField) {
      this.adaptedLongField = adaptedLongField;
      __optional_isset.set(__ADAPTEDLONGFIELD_ISSET_ID, true);
      return this;
    }

    public Builder setDoubleAdaptedField(final long doubleAdaptedField) {
      this.doubleAdaptedField = doubleAdaptedField;
      __optional_isset.set(__DOUBLEADAPTEDFIELD_ISSET_ID, true);
      return this;
    }

    public Foo build() {
      Foo result = new Foo();
      if (__optional_isset.get(__INTFIELD_ISSET_ID)) {
        result.setIntField(this.intField);
      }
      if (__optional_isset.get(__OPTIONALINTFIELD_ISSET_ID)) {
        result.setOptionalIntField(this.optionalIntField);
      }
      if (__optional_isset.get(__INTFIELDWITHDEFAULT_ISSET_ID)) {
        result.setIntFieldWithDefault(this.intFieldWithDefault);
      }
      result.setSetField(this.setField);
      result.setOptionalSetField(this.optionalSetField);
      result.setMapField(this.mapField);
      result.setOptionalMapField(this.optionalMapField);
      result.setBinaryField(this.binaryField);
      if (__optional_isset.get(__LONGFIELD_ISSET_ID)) {
        result.setLongField(this.longField);
      }
      if (__optional_isset.get(__ADAPTEDLONGFIELD_ISSET_ID)) {
        result.setAdaptedLongField(this.adaptedLongField);
      }
      if (__optional_isset.get(__DOUBLEADAPTEDFIELD_ISSET_ID)) {
        result.setDoubleAdaptedField(this.doubleAdaptedField);
      }
      return result;
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Foo(Foo other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.intField = TBaseHelper.deepCopy(other.intField);
    this.optionalIntField = TBaseHelper.deepCopy(other.optionalIntField);
    this.intFieldWithDefault = TBaseHelper.deepCopy(other.intFieldWithDefault);
    if (other.isSetSetField()) {
      this.setField = TBaseHelper.deepCopy(other.setField);
    }
    if (other.isSetOptionalSetField()) {
      this.optionalSetField = TBaseHelper.deepCopy(other.optionalSetField);
    }
    if (other.isSetMapField()) {
      this.mapField = TBaseHelper.deepCopy(other.mapField);
    }
    if (other.isSetOptionalMapField()) {
      this.optionalMapField = TBaseHelper.deepCopy(other.optionalMapField);
    }
    if (other.isSetBinaryField()) {
      this.binaryField = TBaseHelper.deepCopy(other.binaryField);
    }
    this.longField = TBaseHelper.deepCopy(other.longField);
    this.adaptedLongField = TBaseHelper.deepCopy(other.adaptedLongField);
    this.doubleAdaptedField = TBaseHelper.deepCopy(other.doubleAdaptedField);
  }

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

  public int getIntField() {
    return this.intField;
  }

  public Foo setIntField(int intField) {
    this.intField = intField;
    setIntFieldIsSet(true);
    return this;
  }

  public void unsetIntField() {
    __isset_bit_vector.clear(__INTFIELD_ISSET_ID);
  }

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

  public void setIntFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__INTFIELD_ISSET_ID, __value);
  }

  public int getOptionalIntField() {
    return this.optionalIntField;
  }

  public Foo setOptionalIntField(int optionalIntField) {
    this.optionalIntField = optionalIntField;
    setOptionalIntFieldIsSet(true);
    return this;
  }

  public void unsetOptionalIntField() {
    __isset_bit_vector.clear(__OPTIONALINTFIELD_ISSET_ID);
  }

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

  public void setOptionalIntFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__OPTIONALINTFIELD_ISSET_ID, __value);
  }

  public int getIntFieldWithDefault() {
    return this.intFieldWithDefault;
  }

  public Foo setIntFieldWithDefault(int intFieldWithDefault) {
    this.intFieldWithDefault = intFieldWithDefault;
    setIntFieldWithDefaultIsSet(true);
    return this;
  }

  public void unsetIntFieldWithDefault() {
    __isset_bit_vector.clear(__INTFIELDWITHDEFAULT_ISSET_ID);
  }

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

  public void setIntFieldWithDefaultIsSet(boolean __value) {
    __isset_bit_vector.set(__INTFIELDWITHDEFAULT_ISSET_ID, __value);
  }

  public Set<String> getSetField() {
    return this.setField;
  }

  public Foo setSetField(Set<String> setField) {
    this.setField = setField;
    return this;
  }

  public void unsetSetField() {
    this.setField = null;
  }

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

  public void setSetFieldIsSet(boolean __value) {
    if (!__value) {
      this.setField = null;
    }
  }

  public Set<String> getOptionalSetField() {
    return this.optionalSetField;
  }

  public Foo setOptionalSetField(Set<String> optionalSetField) {
    this.optionalSetField = optionalSetField;
    return this;
  }

  public void unsetOptionalSetField() {
    this.optionalSetField = null;
  }

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

  public void setOptionalSetFieldIsSet(boolean __value) {
    if (!__value) {
      this.optionalSetField = null;
    }
  }

  public Map<String,List<String>> getMapField() {
    return this.mapField;
  }

  public Foo setMapField(Map<String,List<String>> mapField) {
    this.mapField = mapField;
    return this;
  }

  public void unsetMapField() {
    this.mapField = null;
  }

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

  public void setMapFieldIsSet(boolean __value) {
    if (!__value) {
      this.mapField = null;
    }
  }

  public Map<String,List<String>> getOptionalMapField() {
    return this.optionalMapField;
  }

  public Foo setOptionalMapField(Map<String,List<String>> optionalMapField) {
    this.optionalMapField = optionalMapField;
    return this;
  }

  public void unsetOptionalMapField() {
    this.optionalMapField = null;
  }

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

  public void setOptionalMapFieldIsSet(boolean __value) {
    if (!__value) {
      this.optionalMapField = null;
    }
  }

  public byte[] getBinaryField() {
    return this.binaryField;
  }

  public Foo setBinaryField(byte[] binaryField) {
    this.binaryField = binaryField;
    return this;
  }

  public void unsetBinaryField() {
    this.binaryField = null;
  }

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

  public void setBinaryFieldIsSet(boolean __value) {
    if (!__value) {
      this.binaryField = null;
    }
  }

  public long getLongField() {
    return this.longField;
  }

  public Foo setLongField(long longField) {
    this.longField = longField;
    setLongFieldIsSet(true);
    return this;
  }

  public void unsetLongField() {
    __isset_bit_vector.clear(__LONGFIELD_ISSET_ID);
  }

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

  public void setLongFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__LONGFIELD_ISSET_ID, __value);
  }

  public long getAdaptedLongField() {
    return this.adaptedLongField;
  }

  public Foo setAdaptedLongField(long adaptedLongField) {
    this.adaptedLongField = adaptedLongField;
    setAdaptedLongFieldIsSet(true);
    return this;
  }

  public void unsetAdaptedLongField() {
    __isset_bit_vector.clear(__ADAPTEDLONGFIELD_ISSET_ID);
  }

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

  public void setAdaptedLongFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__ADAPTEDLONGFIELD_ISSET_ID, __value);
  }

  public long getDoubleAdaptedField() {
    return this.doubleAdaptedField;
  }

  public Foo setDoubleAdaptedField(long doubleAdaptedField) {
    this.doubleAdaptedField = doubleAdaptedField;
    setDoubleAdaptedFieldIsSet(true);
    return this;
  }

  public void unsetDoubleAdaptedField() {
    __isset_bit_vector.clear(__DOUBLEADAPTEDFIELD_ISSET_ID);
  }

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

  public void setDoubleAdaptedFieldIsSet(boolean __value) {
    __isset_bit_vector.set(__DOUBLEADAPTEDFIELD_ISSET_ID, __value);
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case INTFIELD:
      if (__value == null) {
        unsetIntField();
      } else {
        setIntField((Integer)__value);
      }
      break;

    case OPTIONALINTFIELD:
      if (__value == null) {
        unsetOptionalIntField();
      } else {
        setOptionalIntField((Integer)__value);
      }
      break;

    case INTFIELDWITHDEFAULT:
      if (__value == null) {
        unsetIntFieldWithDefault();
      } else {
        setIntFieldWithDefault((Integer)__value);
      }
      break;

    case SETFIELD:
      if (__value == null) {
        unsetSetField();
      } else {
        setSetField((Set<String>)__value);
      }
      break;

    case OPTIONALSETFIELD:
      if (__value == null) {
        unsetOptionalSetField();
      } else {
        setOptionalSetField((Set<String>)__value);
      }
      break;

    case MAPFIELD:
      if (__value == null) {
        unsetMapField();
      } else {
        setMapField((Map<String,List<String>>)__value);
      }
      break;

    case OPTIONALMAPFIELD:
      if (__value == null) {
        unsetOptionalMapField();
      } else {
        setOptionalMapField((Map<String,List<String>>)__value);
      }
      break;

    case BINARYFIELD:
      if (__value == null) {
        unsetBinaryField();
      } else {
        setBinaryField((byte[])__value);
      }
      break;

    case LONGFIELD:
      if (__value == null) {
        unsetLongField();
      } else {
        setLongField((Long)__value);
      }
      break;

    case ADAPTEDLONGFIELD:
      if (__value == null) {
        unsetAdaptedLongField();
      } else {
        setAdaptedLongField((Long)__value);
      }
      break;

    case DOUBLEADAPTEDFIELD:
      if (__value == null) {
        unsetDoubleAdaptedField();
      } else {
        setDoubleAdaptedField((Long)__value);
      }
      break;

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

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case INTFIELD:
      return new Integer(getIntField());

    case OPTIONALINTFIELD:
      return new Integer(getOptionalIntField());

    case INTFIELDWITHDEFAULT:
      return new Integer(getIntFieldWithDefault());

    case SETFIELD:
      return getSetField();

    case OPTIONALSETFIELD:
      return getOptionalSetField();

    case MAPFIELD:
      return getMapField();

    case OPTIONALMAPFIELD:
      return getOptionalMapField();

    case BINARYFIELD:
      return getBinaryField();

    case LONGFIELD:
      return new Long(getLongField());

    case ADAPTEDLONGFIELD:
      return new Long(getAdaptedLongField());

    case DOUBLEADAPTEDFIELD:
      return new Long(getDoubleAdaptedField());

    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 Foo))
      return false;
    Foo that = (Foo)_that;

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

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

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

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

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

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

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

    if (!TBaseHelper.equalsSlow(this.isSetBinaryField(), that.isSetBinaryField(), this.binaryField, that.binaryField)) { return false; }

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

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

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

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {intField, optionalIntField, intFieldWithDefault, setField, optionalSetField, mapField, optionalMapField, binaryField, longField, adaptedLongField, doubleAdaptedField});
  }

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

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

    lastComparison = Boolean.valueOf(isSetIntField()).compareTo(other.isSetIntField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(intField, other.intField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOptionalIntField()).compareTo(other.isSetOptionalIntField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(optionalIntField, other.optionalIntField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetIntFieldWithDefault()).compareTo(other.isSetIntFieldWithDefault());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(intFieldWithDefault, other.intFieldWithDefault);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSetField()).compareTo(other.isSetSetField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(setField, other.setField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOptionalSetField()).compareTo(other.isSetOptionalSetField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(optionalSetField, other.optionalSetField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMapField()).compareTo(other.isSetMapField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(mapField, other.mapField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOptionalMapField()).compareTo(other.isSetOptionalMapField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(optionalMapField, other.optionalMapField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetBinaryField()).compareTo(other.isSetBinaryField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(binaryField, other.binaryField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetLongField()).compareTo(other.isSetLongField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(longField, other.longField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetAdaptedLongField()).compareTo(other.isSetAdaptedLongField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(adaptedLongField, other.adaptedLongField);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetDoubleAdaptedField()).compareTo(other.isSetDoubleAdaptedField());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(doubleAdaptedField, other.doubleAdaptedField);
    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 INTFIELD:
          if (__field.type == TType.I32) {
            this.intField = iprot.readI32();
            setIntFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OPTIONALINTFIELD:
          if (__field.type == TType.I32) {
            this.optionalIntField = iprot.readI32();
            setOptionalIntFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case INTFIELDWITHDEFAULT:
          if (__field.type == TType.I32) {
            this.intFieldWithDefault = iprot.readI32();
            setIntFieldWithDefaultIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case SETFIELD:
          if (__field.type == TType.SET) {
            {
              TSet _set3 = iprot.readSetBegin();
              this.setField = new HashSet<String>(Math.max(0, 2*_set3.size));
              for (int _i4 = 0; 
                   (_set3.size < 0) ? iprot.peekSet() : (_i4 < _set3.size); 
                   ++_i4)
              {
                String _elem5;
                _elem5 = iprot.readString();
                this.setField.add(_elem5);
              }
              iprot.readSetEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OPTIONALSETFIELD:
          if (__field.type == TType.SET) {
            {
              TSet _set6 = iprot.readSetBegin();
              this.optionalSetField = new HashSet<String>(Math.max(0, 2*_set6.size));
              for (int _i7 = 0; 
                   (_set6.size < 0) ? iprot.peekSet() : (_i7 < _set6.size); 
                   ++_i7)
              {
                String _elem8;
                _elem8 = iprot.readString();
                this.optionalSetField.add(_elem8);
              }
              iprot.readSetEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case MAPFIELD:
          if (__field.type == TType.MAP) {
            {
              TMap _map9 = iprot.readMapBegin();
              this.mapField = new HashMap<String,List<String>>(Math.max(0, 2*_map9.size));
              for (int _i10 = 0; 
                   (_map9.size < 0) ? iprot.peekMap() : (_i10 < _map9.size); 
                   ++_i10)
              {
                String _key11;
                List<String> _val12;
                _key11 = iprot.readString();
                {
                  TList _list13 = iprot.readListBegin();
                  _val12 = new ArrayList<String>(Math.max(0, _list13.size));
                  for (int _i14 = 0; 
                       (_list13.size < 0) ? iprot.peekList() : (_i14 < _list13.size); 
                       ++_i14)
                  {
                    String _elem15;
                    _elem15 = iprot.readString();
                    _val12.add(_elem15);
                  }
                  iprot.readListEnd();
                }
                this.mapField.put(_key11, _val12);
              }
              iprot.readMapEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OPTIONALMAPFIELD:
          if (__field.type == TType.MAP) {
            {
              TMap _map16 = iprot.readMapBegin();
              this.optionalMapField = new HashMap<String,List<String>>(Math.max(0, 2*_map16.size));
              for (int _i17 = 0; 
                   (_map16.size < 0) ? iprot.peekMap() : (_i17 < _map16.size); 
                   ++_i17)
              {
                String _key18;
                List<String> _val19;
                _key18 = iprot.readString();
                {
                  TList _list20 = iprot.readListBegin();
                  _val19 = new ArrayList<String>(Math.max(0, _list20.size));
                  for (int _i21 = 0; 
                       (_list20.size < 0) ? iprot.peekList() : (_i21 < _list20.size); 
                       ++_i21)
                  {
                    String _elem22;
                    _elem22 = iprot.readString();
                    _val19.add(_elem22);
                  }
                  iprot.readListEnd();
                }
                this.optionalMapField.put(_key18, _val19);
              }
              iprot.readMapEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case BINARYFIELD:
          if (__field.type == TType.STRING) {
            this.binaryField = iprot.readBinary();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case LONGFIELD:
          if (__field.type == TType.I64) {
            this.longField = iprot.readI64();
            setLongFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ADAPTEDLONGFIELD:
          if (__field.type == TType.I64) {
            this.adaptedLongField = iprot.readI64();
            setAdaptedLongFieldIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case DOUBLEADAPTEDFIELD:
          if (__field.type == TType.I64) {
            this.doubleAdaptedField = iprot.readI64();
            setDoubleAdaptedFieldIsSet(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(INT_FIELD_FIELD_DESC);
    oprot.writeI32(this.intField);
    oprot.writeFieldEnd();
    if (isSetOptionalIntField()) {
      oprot.writeFieldBegin(OPTIONAL_INT_FIELD_FIELD_DESC);
      oprot.writeI32(this.optionalIntField);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(INT_FIELD_WITH_DEFAULT_FIELD_DESC);
    oprot.writeI32(this.intFieldWithDefault);
    oprot.writeFieldEnd();
    if (this.setField != null) {
      oprot.writeFieldBegin(SET_FIELD_FIELD_DESC);
      {
        oprot.writeSetBegin(new TSet(TType.STRING, this.setField.size()));
        for (String _iter23 : this.setField)        {
          oprot.writeString(_iter23);
        }
        oprot.writeSetEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.optionalSetField != null) {
      if (isSetOptionalSetField()) {
        oprot.writeFieldBegin(OPTIONAL_SET_FIELD_FIELD_DESC);
        {
          oprot.writeSetBegin(new TSet(TType.STRING, this.optionalSetField.size()));
          for (String _iter24 : this.optionalSetField)          {
            oprot.writeString(_iter24);
          }
          oprot.writeSetEnd();
        }
        oprot.writeFieldEnd();
      }
    }
    if (this.mapField != null) {
      oprot.writeFieldBegin(MAP_FIELD_FIELD_DESC);
      {
        oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.mapField.size()));
        for (Map.Entry<String, List<String>> _iter25 : this.mapField.entrySet())        {
          oprot.writeString(_iter25.getKey());
          {
            oprot.writeListBegin(new TList(TType.STRING, _iter25.getValue().size()));
            for (String _iter26 : _iter25.getValue())            {
              oprot.writeString(_iter26);
            }
            oprot.writeListEnd();
          }
        }
        oprot.writeMapEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.optionalMapField != null) {
      if (isSetOptionalMapField()) {
        oprot.writeFieldBegin(OPTIONAL_MAP_FIELD_FIELD_DESC);
        {
          oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.optionalMapField.size()));
          for (Map.Entry<String, List<String>> _iter27 : this.optionalMapField.entrySet())          {
            oprot.writeString(_iter27.getKey());
            {
              oprot.writeListBegin(new TList(TType.STRING, _iter27.getValue().size()));
              for (String _iter28 : _iter27.getValue())              {
                oprot.writeString(_iter28);
              }
              oprot.writeListEnd();
            }
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
    }
    if (this.binaryField != null) {
      oprot.writeFieldBegin(BINARY_FIELD_FIELD_DESC);
      oprot.writeBinary(this.binaryField);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(LONG_FIELD_FIELD_DESC);
    oprot.writeI64(this.longField);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(ADAPTED_LONG_FIELD_FIELD_DESC);
    oprot.writeI64(this.adaptedLongField);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(DOUBLE_ADAPTED_FIELD_FIELD_DESC);
    oprot.writeI64(this.doubleAdaptedField);
    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("Foo");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("intField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getIntField(), indent + 1, prettyPrint));
    first = false;
    if (isSetOptionalIntField())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("optionalIntField");
      sb.append(space);
      sb.append(":").append(space);
      sb.append(TBaseHelper.toString(this.getOptionalIntField(), indent + 1, prettyPrint));
      first = false;
    }
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("intFieldWithDefault");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getIntFieldWithDefault(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("setField");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getSetField() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getSetField(), indent + 1, prettyPrint));
    }
    first = false;
    if (isSetOptionalSetField())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("optionalSetField");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getOptionalSetField() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getOptionalSetField(), indent + 1, prettyPrint));
      }
      first = false;
    }
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("mapField");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getMapField() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getMapField(), indent + 1, prettyPrint));
    }
    first = false;
    if (isSetOptionalMapField())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("optionalMapField");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getOptionalMapField() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getOptionalMapField(), indent + 1, prettyPrint));
      }
      first = false;
    }
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("binaryField");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getBinaryField() == null) {
      sb.append("null");
    } else {
        int __binaryField_size = Math.min(this.getBinaryField().length, 128);
        for (int i = 0; i < __binaryField_size; i++) {
          if (i != 0) sb.append(" ");
          sb.append(Integer.toHexString(this.getBinaryField()[i]).length() > 1 ? Integer.toHexString(this.getBinaryField()[i]).substring(Integer.toHexString(this.getBinaryField()[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.getBinaryField()[i]).toUpperCase());
        }
        if (this.getBinaryField().length > 128) sb.append(" ...");
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("longField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getLongField(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("adaptedLongField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getAdaptedLongField(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("doubleAdaptedField");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getDoubleAdaptedField(), 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
  }

}

