/**
 * Autogenerated by Thrift Compiler (0.8.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.hypertable.thriftgen;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Describes an AccessGroup
 * <dl>
 *   <dt>name</dt>
 *   <dd>Name of the access group</dd>
 * 
 *   <dt>in_memory</dt>
 *   <dd>Is this access group in memory</dd>
 * 
 *   <dt>replication</dt>
 *   <dd>Replication factor for this AG</dd>
 * 
 *   <dt>blocksize</dt>
 *   <dd>Specifies blocksize for this AG</dd>
 * 
 *   <dt>compressor</dt>
 *   <dd>Specifies compressor for this AG</dd>
 * 
 *   <dt>bloom_filter</dt>
 *   <dd>Specifies bloom filter type</dd>
 * 
 *   <dt>columns</dt>
 *   <dd>Specifies list of column families in this AG</dd>
 * </dl>
 */
public class AccessGroup implements org.apache.thrift.TBase<AccessGroup, AccessGroup._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AccessGroup");

  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField IN_MEMORY_FIELD_DESC = new org.apache.thrift.protocol.TField("in_memory", org.apache.thrift.protocol.TType.BOOL, (short)2);
  private static final org.apache.thrift.protocol.TField REPLICATION_FIELD_DESC = new org.apache.thrift.protocol.TField("replication", org.apache.thrift.protocol.TType.I16, (short)3);
  private static final org.apache.thrift.protocol.TField BLOCKSIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("blocksize", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField COMPRESSOR_FIELD_DESC = new org.apache.thrift.protocol.TField("compressor", org.apache.thrift.protocol.TType.STRING, (short)5);
  private static final org.apache.thrift.protocol.TField BLOOM_FILTER_FIELD_DESC = new org.apache.thrift.protocol.TField("bloom_filter", org.apache.thrift.protocol.TType.STRING, (short)6);
  private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)7);

  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new AccessGroupStandardSchemeFactory());
    schemes.put(TupleScheme.class, new AccessGroupTupleSchemeFactory());
  }

  public String name; // optional
  public boolean in_memory; // optional
  public short replication; // optional
  public int blocksize; // optional
  public String compressor; // optional
  public String bloom_filter; // optional
  public List<ColumnFamily> columns; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    NAME((short)1, "name"),
    IN_MEMORY((short)2, "in_memory"),
    REPLICATION((short)3, "replication"),
    BLOCKSIZE((short)4, "blocksize"),
    COMPRESSOR((short)5, "compressor"),
    BLOOM_FILTER((short)6, "bloom_filter"),
    COLUMNS((short)7, "columns");

    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: // NAME
          return NAME;
        case 2: // IN_MEMORY
          return IN_MEMORY;
        case 3: // REPLICATION
          return REPLICATION;
        case 4: // BLOCKSIZE
          return BLOCKSIZE;
        case 5: // COMPRESSOR
          return COMPRESSOR;
        case 6: // BLOOM_FILTER
          return BLOOM_FILTER;
        case 7: // COLUMNS
          return COLUMNS;
        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 __IN_MEMORY_ISSET_ID = 0;
  private static final int __REPLICATION_ISSET_ID = 1;
  private static final int __BLOCKSIZE_ISSET_ID = 2;
  private BitSet __isset_bit_vector = new BitSet(3);
  private _Fields optionals[] = {_Fields.NAME,_Fields.IN_MEMORY,_Fields.REPLICATION,_Fields.BLOCKSIZE,_Fields.COMPRESSOR,_Fields.BLOOM_FILTER,_Fields.COLUMNS};
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.IN_MEMORY, new org.apache.thrift.meta_data.FieldMetaData("in_memory", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.REPLICATION, new org.apache.thrift.meta_data.FieldMetaData("replication", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    tmpMap.put(_Fields.BLOCKSIZE, new org.apache.thrift.meta_data.FieldMetaData("blocksize", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.COMPRESSOR, new org.apache.thrift.meta_data.FieldMetaData("compressor", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.BLOOM_FILTER, new org.apache.thrift.meta_data.FieldMetaData("bloom_filter", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ColumnFamily.class))));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AccessGroup.class, metaDataMap);
  }

  public AccessGroup() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public AccessGroup(AccessGroup other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetName()) {
      this.name = other.name;
    }
    this.in_memory = other.in_memory;
    this.replication = other.replication;
    this.blocksize = other.blocksize;
    if (other.isSetCompressor()) {
      this.compressor = other.compressor;
    }
    if (other.isSetBloom_filter()) {
      this.bloom_filter = other.bloom_filter;
    }
    if (other.isSetColumns()) {
      List<ColumnFamily> __this__columns = new ArrayList<ColumnFamily>();
      for (ColumnFamily other_element : other.columns) {
        __this__columns.add(new ColumnFamily(other_element));
      }
      this.columns = __this__columns;
    }
  }

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

  @Override
  public void clear() {
    this.name = null;
    setIn_memoryIsSet(false);
    this.in_memory = false;
    setReplicationIsSet(false);
    this.replication = 0;
    setBlocksizeIsSet(false);
    this.blocksize = 0;
    this.compressor = null;
    this.bloom_filter = null;
    this.columns = null;
  }

  public String getName() {
    return this.name;
  }

  public AccessGroup setName(String name) {
    this.name = name;
    return this;
  }

  public void unsetName() {
    this.name = null;
  }

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

  public void setNameIsSet(boolean value) {
    if (!value) {
      this.name = null;
    }
  }

  public boolean isIn_memory() {
    return this.in_memory;
  }

  public AccessGroup setIn_memory(boolean in_memory) {
    this.in_memory = in_memory;
    setIn_memoryIsSet(true);
    return this;
  }

  public void unsetIn_memory() {
    __isset_bit_vector.clear(__IN_MEMORY_ISSET_ID);
  }

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

  public void setIn_memoryIsSet(boolean value) {
    __isset_bit_vector.set(__IN_MEMORY_ISSET_ID, value);
  }

  public short getReplication() {
    return this.replication;
  }

  public AccessGroup setReplication(short replication) {
    this.replication = replication;
    setReplicationIsSet(true);
    return this;
  }

  public void unsetReplication() {
    __isset_bit_vector.clear(__REPLICATION_ISSET_ID);
  }

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

  public void setReplicationIsSet(boolean value) {
    __isset_bit_vector.set(__REPLICATION_ISSET_ID, value);
  }

  public int getBlocksize() {
    return this.blocksize;
  }

  public AccessGroup setBlocksize(int blocksize) {
    this.blocksize = blocksize;
    setBlocksizeIsSet(true);
    return this;
  }

  public void unsetBlocksize() {
    __isset_bit_vector.clear(__BLOCKSIZE_ISSET_ID);
  }

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

  public void setBlocksizeIsSet(boolean value) {
    __isset_bit_vector.set(__BLOCKSIZE_ISSET_ID, value);
  }

  public String getCompressor() {
    return this.compressor;
  }

  public AccessGroup setCompressor(String compressor) {
    this.compressor = compressor;
    return this;
  }

  public void unsetCompressor() {
    this.compressor = null;
  }

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

  public void setCompressorIsSet(boolean value) {
    if (!value) {
      this.compressor = null;
    }
  }

  public String getBloom_filter() {
    return this.bloom_filter;
  }

  public AccessGroup setBloom_filter(String bloom_filter) {
    this.bloom_filter = bloom_filter;
    return this;
  }

  public void unsetBloom_filter() {
    this.bloom_filter = null;
  }

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

  public void setBloom_filterIsSet(boolean value) {
    if (!value) {
      this.bloom_filter = null;
    }
  }

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

  public java.util.Iterator<ColumnFamily> getColumnsIterator() {
    return (this.columns == null) ? null : this.columns.iterator();
  }

  public void addToColumns(ColumnFamily elem) {
    if (this.columns == null) {
      this.columns = new ArrayList<ColumnFamily>();
    }
    this.columns.add(elem);
  }

  public List<ColumnFamily> getColumns() {
    return this.columns;
  }

  public AccessGroup setColumns(List<ColumnFamily> columns) {
    this.columns = columns;
    return this;
  }

  public void unsetColumns() {
    this.columns = null;
  }

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

  public void setColumnsIsSet(boolean value) {
    if (!value) {
      this.columns = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case NAME:
      if (value == null) {
        unsetName();
      } else {
        setName((String)value);
      }
      break;

    case IN_MEMORY:
      if (value == null) {
        unsetIn_memory();
      } else {
        setIn_memory((Boolean)value);
      }
      break;

    case REPLICATION:
      if (value == null) {
        unsetReplication();
      } else {
        setReplication((Short)value);
      }
      break;

    case BLOCKSIZE:
      if (value == null) {
        unsetBlocksize();
      } else {
        setBlocksize((Integer)value);
      }
      break;

    case COMPRESSOR:
      if (value == null) {
        unsetCompressor();
      } else {
        setCompressor((String)value);
      }
      break;

    case BLOOM_FILTER:
      if (value == null) {
        unsetBloom_filter();
      } else {
        setBloom_filter((String)value);
      }
      break;

    case COLUMNS:
      if (value == null) {
        unsetColumns();
      } else {
        setColumns((List<ColumnFamily>)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case NAME:
      return getName();

    case IN_MEMORY:
      return Boolean.valueOf(isIn_memory());

    case REPLICATION:
      return Short.valueOf(getReplication());

    case BLOCKSIZE:
      return Integer.valueOf(getBlocksize());

    case COMPRESSOR:
      return getCompressor();

    case BLOOM_FILTER:
      return getBloom_filter();

    case COLUMNS:
      return getColumns();

    }
    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 NAME:
      return isSetName();
    case IN_MEMORY:
      return isSetIn_memory();
    case REPLICATION:
      return isSetReplication();
    case BLOCKSIZE:
      return isSetBlocksize();
    case COMPRESSOR:
      return isSetCompressor();
    case BLOOM_FILTER:
      return isSetBloom_filter();
    case COLUMNS:
      return isSetColumns();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(AccessGroup that) {
    if (that == null)
      return false;

    boolean this_present_name = true && this.isSetName();
    boolean that_present_name = true && that.isSetName();
    if (this_present_name || that_present_name) {
      if (!(this_present_name && that_present_name))
        return false;
      if (!this.name.equals(that.name))
        return false;
    }

    boolean this_present_in_memory = true && this.isSetIn_memory();
    boolean that_present_in_memory = true && that.isSetIn_memory();
    if (this_present_in_memory || that_present_in_memory) {
      if (!(this_present_in_memory && that_present_in_memory))
        return false;
      if (this.in_memory != that.in_memory)
        return false;
    }

    boolean this_present_replication = true && this.isSetReplication();
    boolean that_present_replication = true && that.isSetReplication();
    if (this_present_replication || that_present_replication) {
      if (!(this_present_replication && that_present_replication))
        return false;
      if (this.replication != that.replication)
        return false;
    }

    boolean this_present_blocksize = true && this.isSetBlocksize();
    boolean that_present_blocksize = true && that.isSetBlocksize();
    if (this_present_blocksize || that_present_blocksize) {
      if (!(this_present_blocksize && that_present_blocksize))
        return false;
      if (this.blocksize != that.blocksize)
        return false;
    }

    boolean this_present_compressor = true && this.isSetCompressor();
    boolean that_present_compressor = true && that.isSetCompressor();
    if (this_present_compressor || that_present_compressor) {
      if (!(this_present_compressor && that_present_compressor))
        return false;
      if (!this.compressor.equals(that.compressor))
        return false;
    }

    boolean this_present_bloom_filter = true && this.isSetBloom_filter();
    boolean that_present_bloom_filter = true && that.isSetBloom_filter();
    if (this_present_bloom_filter || that_present_bloom_filter) {
      if (!(this_present_bloom_filter && that_present_bloom_filter))
        return false;
      if (!this.bloom_filter.equals(that.bloom_filter))
        return false;
    }

    boolean this_present_columns = true && this.isSetColumns();
    boolean that_present_columns = true && that.isSetColumns();
    if (this_present_columns || that_present_columns) {
      if (!(this_present_columns && that_present_columns))
        return false;
      if (!this.columns.equals(that.columns))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    return 0;
  }

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

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

    lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.name);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIn_memory()).compareTo(typedOther.isSetIn_memory());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIn_memory()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.in_memory, typedOther.in_memory);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetReplication()).compareTo(typedOther.isSetReplication());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetReplication()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.replication, typedOther.replication);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetBlocksize()).compareTo(typedOther.isSetBlocksize());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBlocksize()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.blocksize, typedOther.blocksize);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetCompressor()).compareTo(typedOther.isSetCompressor());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCompressor()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.compressor, typedOther.compressor);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetBloom_filter()).compareTo(typedOther.isSetBloom_filter());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBloom_filter()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bloom_filter, typedOther.bloom_filter);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetColumns()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, typedOther.columns);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

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

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("AccessGroup(");
    boolean first = true;

    if (isSetName()) {
      sb.append("name:");
      if (this.name == null) {
        sb.append("null");
      } else {
        sb.append(this.name);
      }
      first = false;
    }
    if (isSetIn_memory()) {
      if (!first) sb.append(", ");
      sb.append("in_memory:");
      sb.append(this.in_memory);
      first = false;
    }
    if (isSetReplication()) {
      if (!first) sb.append(", ");
      sb.append("replication:");
      sb.append(this.replication);
      first = false;
    }
    if (isSetBlocksize()) {
      if (!first) sb.append(", ");
      sb.append("blocksize:");
      sb.append(this.blocksize);
      first = false;
    }
    if (isSetCompressor()) {
      if (!first) sb.append(", ");
      sb.append("compressor:");
      if (this.compressor == null) {
        sb.append("null");
      } else {
        sb.append(this.compressor);
      }
      first = false;
    }
    if (isSetBloom_filter()) {
      if (!first) sb.append(", ");
      sb.append("bloom_filter:");
      if (this.bloom_filter == null) {
        sb.append("null");
      } else {
        sb.append(this.bloom_filter);
      }
      first = false;
    }
    if (isSetColumns()) {
      if (!first) sb.append(", ");
      sb.append("columns:");
      if (this.columns == null) {
        sb.append("null");
      } else {
        sb.append(this.columns);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bit_vector = new BitSet(1);
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class AccessGroupStandardSchemeFactory implements SchemeFactory {
    public AccessGroupStandardScheme getScheme() {
      return new AccessGroupStandardScheme();
    }
  }

  private static class AccessGroupStandardScheme extends StandardScheme<AccessGroup> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, AccessGroup struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.name = iprot.readString();
              struct.setNameIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // IN_MEMORY
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.in_memory = iprot.readBool();
              struct.setIn_memoryIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // REPLICATION
            if (schemeField.type == org.apache.thrift.protocol.TType.I16) {
              struct.replication = iprot.readI16();
              struct.setReplicationIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // BLOCKSIZE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.blocksize = iprot.readI32();
              struct.setBlocksizeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // COMPRESSOR
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.compressor = iprot.readString();
              struct.setCompressorIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // BLOOM_FILTER
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.bloom_filter = iprot.readString();
              struct.setBloom_filterIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // COLUMNS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list56 = iprot.readListBegin();
                struct.columns = new ArrayList<ColumnFamily>(_list56.size);
                for (int _i57 = 0; _i57 < _list56.size; ++_i57)
                {
                  ColumnFamily _elem58; // required
                  _elem58 = new ColumnFamily();
                  _elem58.read(iprot);
                  struct.columns.add(_elem58);
                }
                iprot.readListEnd();
              }
              struct.setColumnsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

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

    public void write(org.apache.thrift.protocol.TProtocol oprot, AccessGroup struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.name != null) {
        if (struct.isSetName()) {
          oprot.writeFieldBegin(NAME_FIELD_DESC);
          oprot.writeString(struct.name);
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetIn_memory()) {
        oprot.writeFieldBegin(IN_MEMORY_FIELD_DESC);
        oprot.writeBool(struct.in_memory);
        oprot.writeFieldEnd();
      }
      if (struct.isSetReplication()) {
        oprot.writeFieldBegin(REPLICATION_FIELD_DESC);
        oprot.writeI16(struct.replication);
        oprot.writeFieldEnd();
      }
      if (struct.isSetBlocksize()) {
        oprot.writeFieldBegin(BLOCKSIZE_FIELD_DESC);
        oprot.writeI32(struct.blocksize);
        oprot.writeFieldEnd();
      }
      if (struct.compressor != null) {
        if (struct.isSetCompressor()) {
          oprot.writeFieldBegin(COMPRESSOR_FIELD_DESC);
          oprot.writeString(struct.compressor);
          oprot.writeFieldEnd();
        }
      }
      if (struct.bloom_filter != null) {
        if (struct.isSetBloom_filter()) {
          oprot.writeFieldBegin(BLOOM_FILTER_FIELD_DESC);
          oprot.writeString(struct.bloom_filter);
          oprot.writeFieldEnd();
        }
      }
      if (struct.columns != null) {
        if (struct.isSetColumns()) {
          oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
            for (ColumnFamily _iter59 : struct.columns)
            {
              _iter59.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class AccessGroupTupleSchemeFactory implements SchemeFactory {
    public AccessGroupTupleScheme getScheme() {
      return new AccessGroupTupleScheme();
    }
  }

  private static class AccessGroupTupleScheme extends TupleScheme<AccessGroup> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, AccessGroup struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetName()) {
        optionals.set(0);
      }
      if (struct.isSetIn_memory()) {
        optionals.set(1);
      }
      if (struct.isSetReplication()) {
        optionals.set(2);
      }
      if (struct.isSetBlocksize()) {
        optionals.set(3);
      }
      if (struct.isSetCompressor()) {
        optionals.set(4);
      }
      if (struct.isSetBloom_filter()) {
        optionals.set(5);
      }
      if (struct.isSetColumns()) {
        optionals.set(6);
      }
      oprot.writeBitSet(optionals, 7);
      if (struct.isSetName()) {
        oprot.writeString(struct.name);
      }
      if (struct.isSetIn_memory()) {
        oprot.writeBool(struct.in_memory);
      }
      if (struct.isSetReplication()) {
        oprot.writeI16(struct.replication);
      }
      if (struct.isSetBlocksize()) {
        oprot.writeI32(struct.blocksize);
      }
      if (struct.isSetCompressor()) {
        oprot.writeString(struct.compressor);
      }
      if (struct.isSetBloom_filter()) {
        oprot.writeString(struct.bloom_filter);
      }
      if (struct.isSetColumns()) {
        {
          oprot.writeI32(struct.columns.size());
          for (ColumnFamily _iter60 : struct.columns)
          {
            _iter60.write(oprot);
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, AccessGroup struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(7);
      if (incoming.get(0)) {
        struct.name = iprot.readString();
        struct.setNameIsSet(true);
      }
      if (incoming.get(1)) {
        struct.in_memory = iprot.readBool();
        struct.setIn_memoryIsSet(true);
      }
      if (incoming.get(2)) {
        struct.replication = iprot.readI16();
        struct.setReplicationIsSet(true);
      }
      if (incoming.get(3)) {
        struct.blocksize = iprot.readI32();
        struct.setBlocksizeIsSet(true);
      }
      if (incoming.get(4)) {
        struct.compressor = iprot.readString();
        struct.setCompressorIsSet(true);
      }
      if (incoming.get(5)) {
        struct.bloom_filter = iprot.readString();
        struct.setBloom_filterIsSet(true);
      }
      if (incoming.get(6)) {
        {
          org.apache.thrift.protocol.TList _list61 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.columns = new ArrayList<ColumnFamily>(_list61.size);
          for (int _i62 = 0; _i62 < _list61.size; ++_i62)
          {
            ColumnFamily _elem63; // required
            _elem63 = new ColumnFamily();
            _elem63.read(iprot);
            struct.columns.add(_elem63);
          }
        }
        struct.setColumnsIsSet(true);
      }
    }
  }

}

