/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package ytx;

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 org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
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 javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-3-30")
public class Message implements org.apache.thrift.TBase<Message, Message._Fields>, java.io.Serializable, Cloneable, Comparable<Message> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Message");

  private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField DATETIME_FIELD_DESC = new org.apache.thrift.protocol.TField("datetime", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField CONTENT_FIELD_DESC = new org.apache.thrift.protocol.TField("content", org.apache.thrift.protocol.TType.STRING, (short)4);
  private static final org.apache.thrift.protocol.TField FROM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("fromId", org.apache.thrift.protocol.TType.STRING, (short)5);
  private static final org.apache.thrift.protocol.TField FROM_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("fromName", org.apache.thrift.protocol.TType.STRING, (short)6);
  private static final org.apache.thrift.protocol.TField TO_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("toId", org.apache.thrift.protocol.TType.STRING, (short)7);
  private static final org.apache.thrift.protocol.TField TO_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("toName", org.apache.thrift.protocol.TType.STRING, (short)8);
  private static final org.apache.thrift.protocol.TField IS_READ_FIELD_DESC = new org.apache.thrift.protocol.TField("isRead", org.apache.thrift.protocol.TType.BOOL, (short)9);

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

  public String id; // required
  public int type; // required
  public String datetime; // required
  public String content; // required
  public String fromId; // required
  public String fromName; // required
  public String toId; // required
  public String toName; // required
  public boolean isRead; // 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 {
    ID((short)1, "id"),
    TYPE((short)2, "type"),
    DATETIME((short)3, "datetime"),
    CONTENT((short)4, "content"),
    FROM_ID((short)5, "fromId"),
    FROM_NAME((short)6, "fromName"),
    TO_ID((short)7, "toId"),
    TO_NAME((short)8, "toName"),
    IS_READ((short)9, "isRead");

    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: // ID
          return ID;
        case 2: // TYPE
          return TYPE;
        case 3: // DATETIME
          return DATETIME;
        case 4: // CONTENT
          return CONTENT;
        case 5: // FROM_ID
          return FROM_ID;
        case 6: // FROM_NAME
          return FROM_NAME;
        case 7: // TO_ID
          return TO_ID;
        case 8: // TO_NAME
          return TO_NAME;
        case 9: // IS_READ
          return IS_READ;
        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 __TYPE_ISSET_ID = 0;
  private static final int __ISREAD_ISSET_ID = 1;
  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.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.DATETIME, new org.apache.thrift.meta_data.FieldMetaData("datetime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.CONTENT, new org.apache.thrift.meta_data.FieldMetaData("content", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.FROM_ID, new org.apache.thrift.meta_data.FieldMetaData("fromId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.FROM_NAME, new org.apache.thrift.meta_data.FieldMetaData("fromName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TO_ID, new org.apache.thrift.meta_data.FieldMetaData("toId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TO_NAME, new org.apache.thrift.meta_data.FieldMetaData("toName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.IS_READ, new org.apache.thrift.meta_data.FieldMetaData("isRead", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Message.class, metaDataMap);
  }

  public Message() {
  }

  public Message(
    String id,
    int type,
    String datetime,
    String content,
    String fromId,
    String fromName,
    String toId,
    String toName,
    boolean isRead)
  {
    this();
    this.id = id;
    this.type = type;
    setTypeIsSet(true);
    this.datetime = datetime;
    this.content = content;
    this.fromId = fromId;
    this.fromName = fromName;
    this.toId = toId;
    this.toName = toName;
    this.isRead = isRead;
    setIsReadIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Message(Message other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetId()) {
      this.id = other.id;
    }
    this.type = other.type;
    if (other.isSetDatetime()) {
      this.datetime = other.datetime;
    }
    if (other.isSetContent()) {
      this.content = other.content;
    }
    if (other.isSetFromId()) {
      this.fromId = other.fromId;
    }
    if (other.isSetFromName()) {
      this.fromName = other.fromName;
    }
    if (other.isSetToId()) {
      this.toId = other.toId;
    }
    if (other.isSetToName()) {
      this.toName = other.toName;
    }
    this.isRead = other.isRead;
  }

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

  @Override
  public void clear() {
    this.id = null;
    setTypeIsSet(false);
    this.type = 0;
    this.datetime = null;
    this.content = null;
    this.fromId = null;
    this.fromName = null;
    this.toId = null;
    this.toName = null;
    setIsReadIsSet(false);
    this.isRead = false;
  }

  public String getId() {
    return this.id;
  }

  public Message setId(String id) {
    this.id = id;
    return this;
  }

  public void unsetId() {
    this.id = null;
  }

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

  public void setIdIsSet(boolean value) {
    if (!value) {
      this.id = null;
    }
  }

  public int getType() {
    return this.type;
  }

  public Message setType(int type) {
    this.type = type;
    setTypeIsSet(true);
    return this;
  }

  public void unsetType() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TYPE_ISSET_ID);
  }

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

  public void setTypeIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TYPE_ISSET_ID, value);
  }

  public String getDatetime() {
    return this.datetime;
  }

  public Message setDatetime(String datetime) {
    this.datetime = datetime;
    return this;
  }

  public void unsetDatetime() {
    this.datetime = null;
  }

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

  public void setDatetimeIsSet(boolean value) {
    if (!value) {
      this.datetime = null;
    }
  }

  public String getContent() {
    return this.content;
  }

  public Message setContent(String content) {
    this.content = content;
    return this;
  }

  public void unsetContent() {
    this.content = null;
  }

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

  public void setContentIsSet(boolean value) {
    if (!value) {
      this.content = null;
    }
  }

  public String getFromId() {
    return this.fromId;
  }

  public Message setFromId(String fromId) {
    this.fromId = fromId;
    return this;
  }

  public void unsetFromId() {
    this.fromId = null;
  }

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

  public void setFromIdIsSet(boolean value) {
    if (!value) {
      this.fromId = null;
    }
  }

  public String getFromName() {
    return this.fromName;
  }

  public Message setFromName(String fromName) {
    this.fromName = fromName;
    return this;
  }

  public void unsetFromName() {
    this.fromName = null;
  }

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

  public void setFromNameIsSet(boolean value) {
    if (!value) {
      this.fromName = null;
    }
  }

  public String getToId() {
    return this.toId;
  }

  public Message setToId(String toId) {
    this.toId = toId;
    return this;
  }

  public void unsetToId() {
    this.toId = null;
  }

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

  public void setToIdIsSet(boolean value) {
    if (!value) {
      this.toId = null;
    }
  }

  public String getToName() {
    return this.toName;
  }

  public Message setToName(String toName) {
    this.toName = toName;
    return this;
  }

  public void unsetToName() {
    this.toName = null;
  }

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

  public void setToNameIsSet(boolean value) {
    if (!value) {
      this.toName = null;
    }
  }

  public boolean isIsRead() {
    return this.isRead;
  }

  public Message setIsRead(boolean isRead) {
    this.isRead = isRead;
    setIsReadIsSet(true);
    return this;
  }

  public void unsetIsRead() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISREAD_ISSET_ID);
  }

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

  public void setIsReadIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISREAD_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case ID:
      if (value == null) {
        unsetId();
      } else {
        setId((String)value);
      }
      break;

    case TYPE:
      if (value == null) {
        unsetType();
      } else {
        setType((Integer)value);
      }
      break;

    case DATETIME:
      if (value == null) {
        unsetDatetime();
      } else {
        setDatetime((String)value);
      }
      break;

    case CONTENT:
      if (value == null) {
        unsetContent();
      } else {
        setContent((String)value);
      }
      break;

    case FROM_ID:
      if (value == null) {
        unsetFromId();
      } else {
        setFromId((String)value);
      }
      break;

    case FROM_NAME:
      if (value == null) {
        unsetFromName();
      } else {
        setFromName((String)value);
      }
      break;

    case TO_ID:
      if (value == null) {
        unsetToId();
      } else {
        setToId((String)value);
      }
      break;

    case TO_NAME:
      if (value == null) {
        unsetToName();
      } else {
        setToName((String)value);
      }
      break;

    case IS_READ:
      if (value == null) {
        unsetIsRead();
      } else {
        setIsRead((Boolean)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case ID:
      return getId();

    case TYPE:
      return Integer.valueOf(getType());

    case DATETIME:
      return getDatetime();

    case CONTENT:
      return getContent();

    case FROM_ID:
      return getFromId();

    case FROM_NAME:
      return getFromName();

    case TO_ID:
      return getToId();

    case TO_NAME:
      return getToName();

    case IS_READ:
      return Boolean.valueOf(isIsRead());

    }
    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 ID:
      return isSetId();
    case TYPE:
      return isSetType();
    case DATETIME:
      return isSetDatetime();
    case CONTENT:
      return isSetContent();
    case FROM_ID:
      return isSetFromId();
    case FROM_NAME:
      return isSetFromName();
    case TO_ID:
      return isSetToId();
    case TO_NAME:
      return isSetToName();
    case IS_READ:
      return isSetIsRead();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_id = true && this.isSetId();
    boolean that_present_id = true && that.isSetId();
    if (this_present_id || that_present_id) {
      if (!(this_present_id && that_present_id))
        return false;
      if (!this.id.equals(that.id))
        return false;
    }

    boolean this_present_type = true;
    boolean that_present_type = true;
    if (this_present_type || that_present_type) {
      if (!(this_present_type && that_present_type))
        return false;
      if (this.type != that.type)
        return false;
    }

    boolean this_present_datetime = true && this.isSetDatetime();
    boolean that_present_datetime = true && that.isSetDatetime();
    if (this_present_datetime || that_present_datetime) {
      if (!(this_present_datetime && that_present_datetime))
        return false;
      if (!this.datetime.equals(that.datetime))
        return false;
    }

    boolean this_present_content = true && this.isSetContent();
    boolean that_present_content = true && that.isSetContent();
    if (this_present_content || that_present_content) {
      if (!(this_present_content && that_present_content))
        return false;
      if (!this.content.equals(that.content))
        return false;
    }

    boolean this_present_fromId = true && this.isSetFromId();
    boolean that_present_fromId = true && that.isSetFromId();
    if (this_present_fromId || that_present_fromId) {
      if (!(this_present_fromId && that_present_fromId))
        return false;
      if (!this.fromId.equals(that.fromId))
        return false;
    }

    boolean this_present_fromName = true && this.isSetFromName();
    boolean that_present_fromName = true && that.isSetFromName();
    if (this_present_fromName || that_present_fromName) {
      if (!(this_present_fromName && that_present_fromName))
        return false;
      if (!this.fromName.equals(that.fromName))
        return false;
    }

    boolean this_present_toId = true && this.isSetToId();
    boolean that_present_toId = true && that.isSetToId();
    if (this_present_toId || that_present_toId) {
      if (!(this_present_toId && that_present_toId))
        return false;
      if (!this.toId.equals(that.toId))
        return false;
    }

    boolean this_present_toName = true && this.isSetToName();
    boolean that_present_toName = true && that.isSetToName();
    if (this_present_toName || that_present_toName) {
      if (!(this_present_toName && that_present_toName))
        return false;
      if (!this.toName.equals(that.toName))
        return false;
    }

    boolean this_present_isRead = true;
    boolean that_present_isRead = true;
    if (this_present_isRead || that_present_isRead) {
      if (!(this_present_isRead && that_present_isRead))
        return false;
      if (this.isRead != that.isRead)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List<Object> list = new ArrayList<Object>();

    boolean present_id = true && (isSetId());
    list.add(present_id);
    if (present_id)
      list.add(id);

    boolean present_type = true;
    list.add(present_type);
    if (present_type)
      list.add(type);

    boolean present_datetime = true && (isSetDatetime());
    list.add(present_datetime);
    if (present_datetime)
      list.add(datetime);

    boolean present_content = true && (isSetContent());
    list.add(present_content);
    if (present_content)
      list.add(content);

    boolean present_fromId = true && (isSetFromId());
    list.add(present_fromId);
    if (present_fromId)
      list.add(fromId);

    boolean present_fromName = true && (isSetFromName());
    list.add(present_fromName);
    if (present_fromName)
      list.add(fromName);

    boolean present_toId = true && (isSetToId());
    list.add(present_toId);
    if (present_toId)
      list.add(toId);

    boolean present_toName = true && (isSetToName());
    list.add(present_toName);
    if (present_toName)
      list.add(toName);

    boolean present_isRead = true;
    list.add(present_isRead);
    if (present_isRead)
      list.add(isRead);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetId()).compareTo(other.isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDatetime()).compareTo(other.isSetDatetime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDatetime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.datetime, other.datetime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetContent()).compareTo(other.isSetContent());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetContent()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.content, other.content);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFromId()).compareTo(other.isSetFromId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFromId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fromId, other.fromId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFromName()).compareTo(other.isSetFromName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFromName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fromName, other.fromName);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetToId()).compareTo(other.isSetToId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetToId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.toId, other.toId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetToName()).compareTo(other.isSetToName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetToName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.toName, other.toName);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIsRead()).compareTo(other.isSetIsRead());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIsRead()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isRead, other.isRead);
      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("Message(");
    boolean first = true;

    sb.append("id:");
    if (this.id == null) {
      sb.append("null");
    } else {
      sb.append(this.id);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("type:");
    sb.append(this.type);
    first = false;
    if (!first) sb.append(", ");
    sb.append("datetime:");
    if (this.datetime == null) {
      sb.append("null");
    } else {
      sb.append(this.datetime);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("content:");
    if (this.content == null) {
      sb.append("null");
    } else {
      sb.append(this.content);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("fromId:");
    if (this.fromId == null) {
      sb.append("null");
    } else {
      sb.append(this.fromId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("fromName:");
    if (this.fromName == null) {
      sb.append("null");
    } else {
      sb.append(this.fromName);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("toId:");
    if (this.toId == null) {
      sb.append("null");
    } else {
      sb.append(this.toId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("toName:");
    if (this.toName == null) {
      sb.append("null");
    } else {
      sb.append(this.toName);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("isRead:");
    sb.append(this.isRead);
    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 MessageStandardSchemeFactory implements SchemeFactory {
    public MessageStandardScheme getScheme() {
      return new MessageStandardScheme();
    }
  }

  private static class MessageStandardScheme extends StandardScheme<Message> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, Message 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: // ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.id = iprot.readString();
              struct.setIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.type = iprot.readI32();
              struct.setTypeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // DATETIME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.datetime = iprot.readString();
              struct.setDatetimeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // CONTENT
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.content = iprot.readString();
              struct.setContentIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // FROM_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.fromId = iprot.readString();
              struct.setFromIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // FROM_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.fromName = iprot.readString();
              struct.setFromNameIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // TO_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.toId = iprot.readString();
              struct.setToIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // TO_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.toName = iprot.readString();
              struct.setToNameIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 9: // IS_READ
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.isRead = iprot.readBool();
              struct.setIsReadIsSet(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, Message struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.id != null) {
        oprot.writeFieldBegin(ID_FIELD_DESC);
        oprot.writeString(struct.id);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
      oprot.writeI32(struct.type);
      oprot.writeFieldEnd();
      if (struct.datetime != null) {
        oprot.writeFieldBegin(DATETIME_FIELD_DESC);
        oprot.writeString(struct.datetime);
        oprot.writeFieldEnd();
      }
      if (struct.content != null) {
        oprot.writeFieldBegin(CONTENT_FIELD_DESC);
        oprot.writeString(struct.content);
        oprot.writeFieldEnd();
      }
      if (struct.fromId != null) {
        oprot.writeFieldBegin(FROM_ID_FIELD_DESC);
        oprot.writeString(struct.fromId);
        oprot.writeFieldEnd();
      }
      if (struct.fromName != null) {
        oprot.writeFieldBegin(FROM_NAME_FIELD_DESC);
        oprot.writeString(struct.fromName);
        oprot.writeFieldEnd();
      }
      if (struct.toId != null) {
        oprot.writeFieldBegin(TO_ID_FIELD_DESC);
        oprot.writeString(struct.toId);
        oprot.writeFieldEnd();
      }
      if (struct.toName != null) {
        oprot.writeFieldBegin(TO_NAME_FIELD_DESC);
        oprot.writeString(struct.toName);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(IS_READ_FIELD_DESC);
      oprot.writeBool(struct.isRead);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class MessageTupleSchemeFactory implements SchemeFactory {
    public MessageTupleScheme getScheme() {
      return new MessageTupleScheme();
    }
  }

  private static class MessageTupleScheme extends TupleScheme<Message> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, Message struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetId()) {
        optionals.set(0);
      }
      if (struct.isSetType()) {
        optionals.set(1);
      }
      if (struct.isSetDatetime()) {
        optionals.set(2);
      }
      if (struct.isSetContent()) {
        optionals.set(3);
      }
      if (struct.isSetFromId()) {
        optionals.set(4);
      }
      if (struct.isSetFromName()) {
        optionals.set(5);
      }
      if (struct.isSetToId()) {
        optionals.set(6);
      }
      if (struct.isSetToName()) {
        optionals.set(7);
      }
      if (struct.isSetIsRead()) {
        optionals.set(8);
      }
      oprot.writeBitSet(optionals, 9);
      if (struct.isSetId()) {
        oprot.writeString(struct.id);
      }
      if (struct.isSetType()) {
        oprot.writeI32(struct.type);
      }
      if (struct.isSetDatetime()) {
        oprot.writeString(struct.datetime);
      }
      if (struct.isSetContent()) {
        oprot.writeString(struct.content);
      }
      if (struct.isSetFromId()) {
        oprot.writeString(struct.fromId);
      }
      if (struct.isSetFromName()) {
        oprot.writeString(struct.fromName);
      }
      if (struct.isSetToId()) {
        oprot.writeString(struct.toId);
      }
      if (struct.isSetToName()) {
        oprot.writeString(struct.toName);
      }
      if (struct.isSetIsRead()) {
        oprot.writeBool(struct.isRead);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, Message struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(9);
      if (incoming.get(0)) {
        struct.id = iprot.readString();
        struct.setIdIsSet(true);
      }
      if (incoming.get(1)) {
        struct.type = iprot.readI32();
        struct.setTypeIsSet(true);
      }
      if (incoming.get(2)) {
        struct.datetime = iprot.readString();
        struct.setDatetimeIsSet(true);
      }
      if (incoming.get(3)) {
        struct.content = iprot.readString();
        struct.setContentIsSet(true);
      }
      if (incoming.get(4)) {
        struct.fromId = iprot.readString();
        struct.setFromIdIsSet(true);
      }
      if (incoming.get(5)) {
        struct.fromName = iprot.readString();
        struct.setFromNameIsSet(true);
      }
      if (incoming.get(6)) {
        struct.toId = iprot.readString();
        struct.setToIdIsSet(true);
      }
      if (incoming.get(7)) {
        struct.toName = iprot.readString();
        struct.setToNameIsSet(true);
      }
      if (incoming.get(8)) {
        struct.isRead = iprot.readBool();
        struct.setIsReadIsSet(true);
      }
    }
  }

}

