/**
 * Autogenerated by Thrift Compiler (0.9.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.hadoop.thriftfs.api;

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 org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
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;

/**
 * Information about a path in HDFS.
 * 
 * Modelled after org.apache.hadoop.fs.FileStatus
 */
public class Stat implements org.apache.thrift.TBase<Stat, Stat._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Stat");

  private static final org.apache.thrift.protocol.TField PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("path", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField IS_DIR_FIELD_DESC = new org.apache.thrift.protocol.TField("isDir", org.apache.thrift.protocol.TType.BOOL, (short)2);
  private static final org.apache.thrift.protocol.TField ATIME_FIELD_DESC = new org.apache.thrift.protocol.TField("atime", org.apache.thrift.protocol.TType.I64, (short)3);
  private static final org.apache.thrift.protocol.TField MTIME_FIELD_DESC = new org.apache.thrift.protocol.TField("mtime", org.apache.thrift.protocol.TType.I64, (short)4);
  private static final org.apache.thrift.protocol.TField PERMS_FIELD_DESC = new org.apache.thrift.protocol.TField("perms", org.apache.thrift.protocol.TType.I16, (short)5);
  private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)6);
  private static final org.apache.thrift.protocol.TField GROUP_FIELD_DESC = new org.apache.thrift.protocol.TField("group", org.apache.thrift.protocol.TType.STRING, (short)7);
  private static final org.apache.thrift.protocol.TField LENGTH_FIELD_DESC = new org.apache.thrift.protocol.TField("length", org.apache.thrift.protocol.TType.I64, (short)13);
  private static final org.apache.thrift.protocol.TField BLOCK_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("blockSize", org.apache.thrift.protocol.TType.I64, (short)14);
  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)15);

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

  /**
   * The path.
   */
  public String path; // required
  /**
   * True:  The path represents a file.
   * False: The path represents a directory.
   */
  public boolean isDir; // required
  /**
   * Access time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public long atime; // required
  /**
   * Modification time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public long mtime; // required
  /**
   * Access permissions
   */
  public short perms; // required
  /**
   * Owner
   */
  public String owner; // required
  /**
   * Group
   */
  public String group; // required
  /**
   * Length (in bytes).
   */
  public long length; // required
  /**
   * Block size (in bytes).
   */
  public long blockSize; // required
  /**
   * Replication factor.
   */
  public short replication; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    /**
     * The path.
     */
    PATH((short)1, "path"),
    /**
     * True:  The path represents a file.
     * False: The path represents a directory.
     */
    IS_DIR((short)2, "isDir"),
    /**
     * Access time (milliseconds since 1970-01-01 00:00 UTC).
     */
    ATIME((short)3, "atime"),
    /**
     * Modification time (milliseconds since 1970-01-01 00:00 UTC).
     */
    MTIME((short)4, "mtime"),
    /**
     * Access permissions
     */
    PERMS((short)5, "perms"),
    /**
     * Owner
     */
    OWNER((short)6, "owner"),
    /**
     * Group
     */
    GROUP((short)7, "group"),
    /**
     * Length (in bytes).
     */
    LENGTH((short)13, "length"),
    /**
     * Block size (in bytes).
     */
    BLOCK_SIZE((short)14, "blockSize"),
    /**
     * Replication factor.
     */
    REPLICATION((short)15, "replication");

    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: // PATH
          return PATH;
        case 2: // IS_DIR
          return IS_DIR;
        case 3: // ATIME
          return ATIME;
        case 4: // MTIME
          return MTIME;
        case 5: // PERMS
          return PERMS;
        case 6: // OWNER
          return OWNER;
        case 7: // GROUP
          return GROUP;
        case 13: // LENGTH
          return LENGTH;
        case 14: // BLOCK_SIZE
          return BLOCK_SIZE;
        case 15: // REPLICATION
          return REPLICATION;
        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 __ISDIR_ISSET_ID = 0;
  private static final int __ATIME_ISSET_ID = 1;
  private static final int __MTIME_ISSET_ID = 2;
  private static final int __PERMS_ISSET_ID = 3;
  private static final int __LENGTH_ISSET_ID = 4;
  private static final int __BLOCKSIZE_ISSET_ID = 5;
  private static final int __REPLICATION_ISSET_ID = 6;
  private byte __isset_bitfield = 0;
  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.PATH, new org.apache.thrift.meta_data.FieldMetaData("path", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.IS_DIR, new org.apache.thrift.meta_data.FieldMetaData("isDir", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.ATIME, new org.apache.thrift.meta_data.FieldMetaData("atime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.MTIME, new org.apache.thrift.meta_data.FieldMetaData("mtime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.PERMS, new org.apache.thrift.meta_data.FieldMetaData("perms", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    tmpMap.put(_Fields.OWNER, new org.apache.thrift.meta_data.FieldMetaData("owner", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.GROUP, new org.apache.thrift.meta_data.FieldMetaData("group", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.LENGTH, new org.apache.thrift.meta_data.FieldMetaData("length", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.BLOCK_SIZE, new org.apache.thrift.meta_data.FieldMetaData("blockSize", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.REPLICATION, new org.apache.thrift.meta_data.FieldMetaData("replication", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Stat.class, metaDataMap);
  }

  public Stat() {
  }

  public Stat(
    String path,
    boolean isDir,
    long atime,
    long mtime,
    short perms,
    String owner,
    String group,
    long length,
    long blockSize,
    short replication)
  {
    this();
    this.path = path;
    this.isDir = isDir;
    setIsDirIsSet(true);
    this.atime = atime;
    setAtimeIsSet(true);
    this.mtime = mtime;
    setMtimeIsSet(true);
    this.perms = perms;
    setPermsIsSet(true);
    this.owner = owner;
    this.group = group;
    this.length = length;
    setLengthIsSet(true);
    this.blockSize = blockSize;
    setBlockSizeIsSet(true);
    this.replication = replication;
    setReplicationIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Stat(Stat other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetPath()) {
      this.path = other.path;
    }
    this.isDir = other.isDir;
    this.atime = other.atime;
    this.mtime = other.mtime;
    this.perms = other.perms;
    if (other.isSetOwner()) {
      this.owner = other.owner;
    }
    if (other.isSetGroup()) {
      this.group = other.group;
    }
    this.length = other.length;
    this.blockSize = other.blockSize;
    this.replication = other.replication;
  }

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

  @Override
  public void clear() {
    this.path = null;
    setIsDirIsSet(false);
    this.isDir = false;
    setAtimeIsSet(false);
    this.atime = 0;
    setMtimeIsSet(false);
    this.mtime = 0;
    setPermsIsSet(false);
    this.perms = 0;
    this.owner = null;
    this.group = null;
    setLengthIsSet(false);
    this.length = 0;
    setBlockSizeIsSet(false);
    this.blockSize = 0;
    setReplicationIsSet(false);
    this.replication = 0;
  }

  /**
   * The path.
   */
  public String getPath() {
    return this.path;
  }

  /**
   * The path.
   */
  public Stat setPath(String path) {
    this.path = path;
    return this;
  }

  public void unsetPath() {
    this.path = null;
  }

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

  public void setPathIsSet(boolean value) {
    if (!value) {
      this.path = null;
    }
  }

  /**
   * True:  The path represents a file.
   * False: The path represents a directory.
   */
  public boolean isIsDir() {
    return this.isDir;
  }

  /**
   * True:  The path represents a file.
   * False: The path represents a directory.
   */
  public Stat setIsDir(boolean isDir) {
    this.isDir = isDir;
    setIsDirIsSet(true);
    return this;
  }

  public void unsetIsDir() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISDIR_ISSET_ID);
  }

  /** Returns true if field isDir is set (has been assigned a value) and false otherwise */
  public boolean isSetIsDir() {
    return EncodingUtils.testBit(__isset_bitfield, __ISDIR_ISSET_ID);
  }

  public void setIsDirIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISDIR_ISSET_ID, value);
  }

  /**
   * Access time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public long getAtime() {
    return this.atime;
  }

  /**
   * Access time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public Stat setAtime(long atime) {
    this.atime = atime;
    setAtimeIsSet(true);
    return this;
  }

  public void unsetAtime() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ATIME_ISSET_ID);
  }

  /** Returns true if field atime is set (has been assigned a value) and false otherwise */
  public boolean isSetAtime() {
    return EncodingUtils.testBit(__isset_bitfield, __ATIME_ISSET_ID);
  }

  public void setAtimeIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ATIME_ISSET_ID, value);
  }

  /**
   * Modification time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public long getMtime() {
    return this.mtime;
  }

  /**
   * Modification time (milliseconds since 1970-01-01 00:00 UTC).
   */
  public Stat setMtime(long mtime) {
    this.mtime = mtime;
    setMtimeIsSet(true);
    return this;
  }

  public void unsetMtime() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MTIME_ISSET_ID);
  }

  /** Returns true if field mtime is set (has been assigned a value) and false otherwise */
  public boolean isSetMtime() {
    return EncodingUtils.testBit(__isset_bitfield, __MTIME_ISSET_ID);
  }

  public void setMtimeIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MTIME_ISSET_ID, value);
  }

  /**
   * Access permissions
   */
  public short getPerms() {
    return this.perms;
  }

  /**
   * Access permissions
   */
  public Stat setPerms(short perms) {
    this.perms = perms;
    setPermsIsSet(true);
    return this;
  }

  public void unsetPerms() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PERMS_ISSET_ID);
  }

  /** Returns true if field perms is set (has been assigned a value) and false otherwise */
  public boolean isSetPerms() {
    return EncodingUtils.testBit(__isset_bitfield, __PERMS_ISSET_ID);
  }

  public void setPermsIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PERMS_ISSET_ID, value);
  }

  /**
   * Owner
   */
  public String getOwner() {
    return this.owner;
  }

  /**
   * Owner
   */
  public Stat setOwner(String owner) {
    this.owner = owner;
    return this;
  }

  public void unsetOwner() {
    this.owner = null;
  }

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

  public void setOwnerIsSet(boolean value) {
    if (!value) {
      this.owner = null;
    }
  }

  /**
   * Group
   */
  public String getGroup() {
    return this.group;
  }

  /**
   * Group
   */
  public Stat setGroup(String group) {
    this.group = group;
    return this;
  }

  public void unsetGroup() {
    this.group = null;
  }

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

  public void setGroupIsSet(boolean value) {
    if (!value) {
      this.group = null;
    }
  }

  /**
   * Length (in bytes).
   */
  public long getLength() {
    return this.length;
  }

  /**
   * Length (in bytes).
   */
  public Stat setLength(long length) {
    this.length = length;
    setLengthIsSet(true);
    return this;
  }

  public void unsetLength() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __LENGTH_ISSET_ID);
  }

  /** Returns true if field length is set (has been assigned a value) and false otherwise */
  public boolean isSetLength() {
    return EncodingUtils.testBit(__isset_bitfield, __LENGTH_ISSET_ID);
  }

  public void setLengthIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LENGTH_ISSET_ID, value);
  }

  /**
   * Block size (in bytes).
   */
  public long getBlockSize() {
    return this.blockSize;
  }

  /**
   * Block size (in bytes).
   */
  public Stat setBlockSize(long blockSize) {
    this.blockSize = blockSize;
    setBlockSizeIsSet(true);
    return this;
  }

  public void unsetBlockSize() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __BLOCKSIZE_ISSET_ID);
  }

  /** Returns true if field blockSize is set (has been assigned a value) and false otherwise */
  public boolean isSetBlockSize() {
    return EncodingUtils.testBit(__isset_bitfield, __BLOCKSIZE_ISSET_ID);
  }

  public void setBlockSizeIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __BLOCKSIZE_ISSET_ID, value);
  }

  /**
   * Replication factor.
   */
  public short getReplication() {
    return this.replication;
  }

  /**
   * Replication factor.
   */
  public Stat setReplication(short replication) {
    this.replication = replication;
    setReplicationIsSet(true);
    return this;
  }

  public void unsetReplication() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __REPLICATION_ISSET_ID);
  }

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

  public void setReplicationIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __REPLICATION_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case PATH:
      if (value == null) {
        unsetPath();
      } else {
        setPath((String)value);
      }
      break;

    case IS_DIR:
      if (value == null) {
        unsetIsDir();
      } else {
        setIsDir((Boolean)value);
      }
      break;

    case ATIME:
      if (value == null) {
        unsetAtime();
      } else {
        setAtime((Long)value);
      }
      break;

    case MTIME:
      if (value == null) {
        unsetMtime();
      } else {
        setMtime((Long)value);
      }
      break;

    case PERMS:
      if (value == null) {
        unsetPerms();
      } else {
        setPerms((Short)value);
      }
      break;

    case OWNER:
      if (value == null) {
        unsetOwner();
      } else {
        setOwner((String)value);
      }
      break;

    case GROUP:
      if (value == null) {
        unsetGroup();
      } else {
        setGroup((String)value);
      }
      break;

    case LENGTH:
      if (value == null) {
        unsetLength();
      } else {
        setLength((Long)value);
      }
      break;

    case BLOCK_SIZE:
      if (value == null) {
        unsetBlockSize();
      } else {
        setBlockSize((Long)value);
      }
      break;

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

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case PATH:
      return getPath();

    case IS_DIR:
      return Boolean.valueOf(isIsDir());

    case ATIME:
      return Long.valueOf(getAtime());

    case MTIME:
      return Long.valueOf(getMtime());

    case PERMS:
      return Short.valueOf(getPerms());

    case OWNER:
      return getOwner();

    case GROUP:
      return getGroup();

    case LENGTH:
      return Long.valueOf(getLength());

    case BLOCK_SIZE:
      return Long.valueOf(getBlockSize());

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

    }
    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 PATH:
      return isSetPath();
    case IS_DIR:
      return isSetIsDir();
    case ATIME:
      return isSetAtime();
    case MTIME:
      return isSetMtime();
    case PERMS:
      return isSetPerms();
    case OWNER:
      return isSetOwner();
    case GROUP:
      return isSetGroup();
    case LENGTH:
      return isSetLength();
    case BLOCK_SIZE:
      return isSetBlockSize();
    case REPLICATION:
      return isSetReplication();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_path = true && this.isSetPath();
    boolean that_present_path = true && that.isSetPath();
    if (this_present_path || that_present_path) {
      if (!(this_present_path && that_present_path))
        return false;
      if (!this.path.equals(that.path))
        return false;
    }

    boolean this_present_isDir = true;
    boolean that_present_isDir = true;
    if (this_present_isDir || that_present_isDir) {
      if (!(this_present_isDir && that_present_isDir))
        return false;
      if (this.isDir != that.isDir)
        return false;
    }

    boolean this_present_atime = true;
    boolean that_present_atime = true;
    if (this_present_atime || that_present_atime) {
      if (!(this_present_atime && that_present_atime))
        return false;
      if (this.atime != that.atime)
        return false;
    }

    boolean this_present_mtime = true;
    boolean that_present_mtime = true;
    if (this_present_mtime || that_present_mtime) {
      if (!(this_present_mtime && that_present_mtime))
        return false;
      if (this.mtime != that.mtime)
        return false;
    }

    boolean this_present_perms = true;
    boolean that_present_perms = true;
    if (this_present_perms || that_present_perms) {
      if (!(this_present_perms && that_present_perms))
        return false;
      if (this.perms != that.perms)
        return false;
    }

    boolean this_present_owner = true && this.isSetOwner();
    boolean that_present_owner = true && that.isSetOwner();
    if (this_present_owner || that_present_owner) {
      if (!(this_present_owner && that_present_owner))
        return false;
      if (!this.owner.equals(that.owner))
        return false;
    }

    boolean this_present_group = true && this.isSetGroup();
    boolean that_present_group = true && that.isSetGroup();
    if (this_present_group || that_present_group) {
      if (!(this_present_group && that_present_group))
        return false;
      if (!this.group.equals(that.group))
        return false;
    }

    boolean this_present_length = true;
    boolean that_present_length = true;
    if (this_present_length || that_present_length) {
      if (!(this_present_length && that_present_length))
        return false;
      if (this.length != that.length)
        return false;
    }

    boolean this_present_blockSize = true;
    boolean that_present_blockSize = true;
    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_replication = true;
    boolean that_present_replication = true;
    if (this_present_replication || that_present_replication) {
      if (!(this_present_replication && that_present_replication))
        return false;
      if (this.replication != that.replication)
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetPath()).compareTo(typedOther.isSetPath());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPath()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.path, typedOther.path);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIsDir()).compareTo(typedOther.isSetIsDir());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIsDir()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isDir, typedOther.isDir);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetAtime()).compareTo(typedOther.isSetAtime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAtime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.atime, typedOther.atime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMtime()).compareTo(typedOther.isSetMtime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMtime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mtime, typedOther.mtime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPerms()).compareTo(typedOther.isSetPerms());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPerms()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.perms, typedOther.perms);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetOwner()).compareTo(typedOther.isSetOwner());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOwner()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.owner, typedOther.owner);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetGroup()).compareTo(typedOther.isSetGroup());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGroup()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.group, typedOther.group);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetLength()).compareTo(typedOther.isSetLength());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLength()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.length, typedOther.length);
      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(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;
      }
    }
    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("Stat(");
    boolean first = true;

    sb.append("path:");
    if (this.path == null) {
      sb.append("null");
    } else {
      sb.append(this.path);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("isDir:");
    sb.append(this.isDir);
    first = false;
    if (!first) sb.append(", ");
    sb.append("atime:");
    sb.append(this.atime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("mtime:");
    sb.append(this.mtime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("perms:");
    sb.append(this.perms);
    first = false;
    if (!first) sb.append(", ");
    sb.append("owner:");
    if (this.owner == null) {
      sb.append("null");
    } else {
      sb.append(this.owner);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("group:");
    if (this.group == null) {
      sb.append("null");
    } else {
      sb.append(this.group);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("length:");
    sb.append(this.length);
    first = false;
    if (!first) sb.append(", ");
    sb.append("blockSize:");
    sb.append(this.blockSize);
    first = false;
    if (!first) sb.append(", ");
    sb.append("replication:");
    sb.append(this.replication);
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

  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_bitfield = 0;
      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 StatStandardSchemeFactory implements SchemeFactory {
    public StatStandardScheme getScheme() {
      return new StatStandardScheme();
    }
  }

  private static class StatStandardScheme extends StandardScheme<Stat> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, Stat 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: // PATH
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.path = iprot.readString();
              struct.setPathIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // IS_DIR
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.isDir = iprot.readBool();
              struct.setIsDirIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // ATIME
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.atime = iprot.readI64();
              struct.setAtimeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // MTIME
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.mtime = iprot.readI64();
              struct.setMtimeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // PERMS
            if (schemeField.type == org.apache.thrift.protocol.TType.I16) {
              struct.perms = iprot.readI16();
              struct.setPermsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // OWNER
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.owner = iprot.readString();
              struct.setOwnerIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // GROUP
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.group = iprot.readString();
              struct.setGroupIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 13: // LENGTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.length = iprot.readI64();
              struct.setLengthIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 14: // BLOCK_SIZE
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.blockSize = iprot.readI64();
              struct.setBlockSizeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 15: // 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;
          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, Stat struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.path != null) {
        oprot.writeFieldBegin(PATH_FIELD_DESC);
        oprot.writeString(struct.path);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(IS_DIR_FIELD_DESC);
      oprot.writeBool(struct.isDir);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ATIME_FIELD_DESC);
      oprot.writeI64(struct.atime);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(MTIME_FIELD_DESC);
      oprot.writeI64(struct.mtime);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(PERMS_FIELD_DESC);
      oprot.writeI16(struct.perms);
      oprot.writeFieldEnd();
      if (struct.owner != null) {
        oprot.writeFieldBegin(OWNER_FIELD_DESC);
        oprot.writeString(struct.owner);
        oprot.writeFieldEnd();
      }
      if (struct.group != null) {
        oprot.writeFieldBegin(GROUP_FIELD_DESC);
        oprot.writeString(struct.group);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(LENGTH_FIELD_DESC);
      oprot.writeI64(struct.length);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(BLOCK_SIZE_FIELD_DESC);
      oprot.writeI64(struct.blockSize);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(REPLICATION_FIELD_DESC);
      oprot.writeI16(struct.replication);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class StatTupleSchemeFactory implements SchemeFactory {
    public StatTupleScheme getScheme() {
      return new StatTupleScheme();
    }
  }

  private static class StatTupleScheme extends TupleScheme<Stat> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, Stat struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetPath()) {
        optionals.set(0);
      }
      if (struct.isSetIsDir()) {
        optionals.set(1);
      }
      if (struct.isSetAtime()) {
        optionals.set(2);
      }
      if (struct.isSetMtime()) {
        optionals.set(3);
      }
      if (struct.isSetPerms()) {
        optionals.set(4);
      }
      if (struct.isSetOwner()) {
        optionals.set(5);
      }
      if (struct.isSetGroup()) {
        optionals.set(6);
      }
      if (struct.isSetLength()) {
        optionals.set(7);
      }
      if (struct.isSetBlockSize()) {
        optionals.set(8);
      }
      if (struct.isSetReplication()) {
        optionals.set(9);
      }
      oprot.writeBitSet(optionals, 10);
      if (struct.isSetPath()) {
        oprot.writeString(struct.path);
      }
      if (struct.isSetIsDir()) {
        oprot.writeBool(struct.isDir);
      }
      if (struct.isSetAtime()) {
        oprot.writeI64(struct.atime);
      }
      if (struct.isSetMtime()) {
        oprot.writeI64(struct.mtime);
      }
      if (struct.isSetPerms()) {
        oprot.writeI16(struct.perms);
      }
      if (struct.isSetOwner()) {
        oprot.writeString(struct.owner);
      }
      if (struct.isSetGroup()) {
        oprot.writeString(struct.group);
      }
      if (struct.isSetLength()) {
        oprot.writeI64(struct.length);
      }
      if (struct.isSetBlockSize()) {
        oprot.writeI64(struct.blockSize);
      }
      if (struct.isSetReplication()) {
        oprot.writeI16(struct.replication);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, Stat struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(10);
      if (incoming.get(0)) {
        struct.path = iprot.readString();
        struct.setPathIsSet(true);
      }
      if (incoming.get(1)) {
        struct.isDir = iprot.readBool();
        struct.setIsDirIsSet(true);
      }
      if (incoming.get(2)) {
        struct.atime = iprot.readI64();
        struct.setAtimeIsSet(true);
      }
      if (incoming.get(3)) {
        struct.mtime = iprot.readI64();
        struct.setMtimeIsSet(true);
      }
      if (incoming.get(4)) {
        struct.perms = iprot.readI16();
        struct.setPermsIsSet(true);
      }
      if (incoming.get(5)) {
        struct.owner = iprot.readString();
        struct.setOwnerIsSet(true);
      }
      if (incoming.get(6)) {
        struct.group = iprot.readString();
        struct.setGroupIsSet(true);
      }
      if (incoming.get(7)) {
        struct.length = iprot.readI64();
        struct.setLengthIsSet(true);
      }
      if (incoming.get(8)) {
        struct.blockSize = iprot.readI64();
        struct.setBlockSizeIsSet(true);
      }
      if (incoming.get(9)) {
        struct.replication = iprot.readI16();
        struct.setReplicationIsSet(true);
      }
    }
  }

}

