Subversion Repositories SmartDukaan

Rev

Rev 471 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.utils;

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.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

/**
 * Helper service
 * created by @ashish
 * *
 */
public class Mail implements TBase<Mail._Fields>, java.io.Serializable, Cloneable, Comparable<Mail> {
  private static final TStruct STRUCT_DESC = new TStruct("Mail");

  private static final TField TO_FIELD_DESC = new TField("to", TType.LIST, (short)1);
  private static final TField SUBJECT_FIELD_DESC = new TField("subject", TType.STRING, (short)2);
  private static final TField DATA_FIELD_DESC = new TField("data", TType.STRING, (short)3);
  private static final TField SENDER_FIELD_DESC = new TField("sender", TType.STRING, (short)4);
  private static final TField ATTACHMENTS_FIELD_DESC = new TField("attachments", TType.LIST, (short)5);
  private static final TField PASSWORD_FIELD_DESC = new TField("password", TType.STRING, (short)6);

  private List<String> to;
  private String subject;
  private String data;
  private String sender;
  private List<String> attachments;
  private String password;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    TO((short)1, "to"),
    SUBJECT((short)2, "subject"),
    DATA((short)3, "data"),
    SENDER((short)4, "sender"),
    ATTACHMENTS((short)5, "attachments"),
    PASSWORD((short)6, "password");

    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byId.put((int)field._thriftId, field);
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      return byId.get(fieldId);
    }

    /**
     * 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

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.TO, new FieldMetaData("to", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new FieldValueMetaData(TType.STRING))));
    put(_Fields.SUBJECT, new FieldMetaData("subject", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.DATA, new FieldMetaData("data", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.SENDER, new FieldMetaData("sender", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.ATTACHMENTS, new FieldMetaData("attachments", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new FieldValueMetaData(TType.STRING))));
    put(_Fields.PASSWORD, new FieldMetaData("password", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
  }});

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

  public Mail() {
  }

  public Mail(
    List<String> to,
    String subject,
    String data,
    String sender,
    List<String> attachments,
    String password)
  {
    this();
    this.to = to;
    this.subject = subject;
    this.data = data;
    this.sender = sender;
    this.attachments = attachments;
    this.password = password;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Mail(Mail other) {
    if (other.isSetTo()) {
      List<String> __this__to = new ArrayList<String>();
      for (String other_element : other.to) {
        __this__to.add(other_element);
      }
      this.to = __this__to;
    }
    if (other.isSetSubject()) {
      this.subject = other.subject;
    }
    if (other.isSetData()) {
      this.data = other.data;
    }
    if (other.isSetSender()) {
      this.sender = other.sender;
    }
    if (other.isSetAttachments()) {
      List<String> __this__attachments = new ArrayList<String>();
      for (String other_element : other.attachments) {
        __this__attachments.add(other_element);
      }
      this.attachments = __this__attachments;
    }
    if (other.isSetPassword()) {
      this.password = other.password;
    }
  }

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

  @Deprecated
  public Mail clone() {
    return new Mail(this);
  }

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

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

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

  public List<String> getTo() {
    return this.to;
  }

  public Mail setTo(List<String> to) {
    this.to = to;
    return this;
  }

  public void unsetTo() {
    this.to = null;
  }

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

  public void setToIsSet(boolean value) {
    if (!value) {
      this.to = null;
    }
  }

  public String getSubject() {
    return this.subject;
  }

  public Mail setSubject(String subject) {
    this.subject = subject;
    return this;
  }

  public void unsetSubject() {
    this.subject = null;
  }

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

  public void setSubjectIsSet(boolean value) {
    if (!value) {
      this.subject = null;
    }
  }

  public String getData() {
    return this.data;
  }

  public Mail setData(String data) {
    this.data = data;
    return this;
  }

  public void unsetData() {
    this.data = null;
  }

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

  public void setDataIsSet(boolean value) {
    if (!value) {
      this.data = null;
    }
  }

  public String getSender() {
    return this.sender;
  }

  public Mail setSender(String sender) {
    this.sender = sender;
    return this;
  }

  public void unsetSender() {
    this.sender = null;
  }

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

  public void setSenderIsSet(boolean value) {
    if (!value) {
      this.sender = null;
    }
  }

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

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

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

  public List<String> getAttachments() {
    return this.attachments;
  }

  public Mail setAttachments(List<String> attachments) {
    this.attachments = attachments;
    return this;
  }

  public void unsetAttachments() {
    this.attachments = null;
  }

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

  public void setAttachmentsIsSet(boolean value) {
    if (!value) {
      this.attachments = null;
    }
  }

  public String getPassword() {
    return this.password;
  }

  public Mail setPassword(String password) {
    this.password = password;
    return this;
  }

  public void unsetPassword() {
    this.password = null;
  }

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

  public void setPasswordIsSet(boolean value) {
    if (!value) {
      this.password = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case TO:
      if (value == null) {
        unsetTo();
      } else {
        setTo((List<String>)value);
      }
      break;

    case SUBJECT:
      if (value == null) {
        unsetSubject();
      } else {
        setSubject((String)value);
      }
      break;

    case DATA:
      if (value == null) {
        unsetData();
      } else {
        setData((String)value);
      }
      break;

    case SENDER:
      if (value == null) {
        unsetSender();
      } else {
        setSender((String)value);
      }
      break;

    case ATTACHMENTS:
      if (value == null) {
        unsetAttachments();
      } else {
        setAttachments((List<String>)value);
      }
      break;

    case PASSWORD:
      if (value == null) {
        unsetPassword();
      } else {
        setPassword((String)value);
      }
      break;

    }
  }

  public void setFieldValue(int fieldID, Object value) {
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case TO:
      return getTo();

    case SUBJECT:
      return getSubject();

    case DATA:
      return getData();

    case SENDER:
      return getSender();

    case ATTACHMENTS:
      return getAttachments();

    case PASSWORD:
      return getPassword();

    }
    throw new IllegalStateException();
  }

  public Object getFieldValue(int fieldId) {
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    switch (field) {
    case TO:
      return isSetTo();
    case SUBJECT:
      return isSetSubject();
    case DATA:
      return isSetData();
    case SENDER:
      return isSetSender();
    case ATTACHMENTS:
      return isSetAttachments();
    case PASSWORD:
      return isSetPassword();
    }
    throw new IllegalStateException();
  }

  public boolean isSet(int fieldID) {
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
  }

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

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

    boolean this_present_to = true && this.isSetTo();
    boolean that_present_to = true && that.isSetTo();
    if (this_present_to || that_present_to) {
      if (!(this_present_to && that_present_to))
        return false;
      if (!this.to.equals(that.to))
        return false;
    }

    boolean this_present_subject = true && this.isSetSubject();
    boolean that_present_subject = true && that.isSetSubject();
    if (this_present_subject || that_present_subject) {
      if (!(this_present_subject && that_present_subject))
        return false;
      if (!this.subject.equals(that.subject))
        return false;
    }

    boolean this_present_data = true && this.isSetData();
    boolean that_present_data = true && that.isSetData();
    if (this_present_data || that_present_data) {
      if (!(this_present_data && that_present_data))
        return false;
      if (!this.data.equals(that.data))
        return false;
    }

    boolean this_present_sender = true && this.isSetSender();
    boolean that_present_sender = true && that.isSetSender();
    if (this_present_sender || that_present_sender) {
      if (!(this_present_sender && that_present_sender))
        return false;
      if (!this.sender.equals(that.sender))
        return false;
    }

    boolean this_present_attachments = true && this.isSetAttachments();
    boolean that_present_attachments = true && that.isSetAttachments();
    if (this_present_attachments || that_present_attachments) {
      if (!(this_present_attachments && that_present_attachments))
        return false;
      if (!this.attachments.equals(that.attachments))
        return false;
    }

    boolean this_present_password = true && this.isSetPassword();
    boolean that_present_password = true && that.isSetPassword();
    if (this_present_password || that_present_password) {
      if (!(this_present_password && that_present_password))
        return false;
      if (!this.password.equals(that.password))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetTo()).compareTo(isSetTo());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(to, typedOther.to);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSubject()).compareTo(isSetSubject());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(subject, typedOther.subject);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetData()).compareTo(isSetData());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(data, typedOther.data);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSender()).compareTo(isSetSender());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(sender, typedOther.sender);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetAttachments()).compareTo(isSetAttachments());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(attachments, typedOther.attachments);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetPassword()).compareTo(isSetPassword());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(password, typedOther.password);
    if (lastComparison != 0) {
      return lastComparison;
    }
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      _Fields fieldId = _Fields.findByThriftId(field.id);
      if (fieldId == null) {
        TProtocolUtil.skip(iprot, field.type);
      } else {
        switch (fieldId) {
          case TO:
            if (field.type == TType.LIST) {
              {
                TList _list0 = iprot.readListBegin();
                this.to = new ArrayList<String>(_list0.size);
                for (int _i1 = 0; _i1 < _list0.size; ++_i1)
                {
                  String _elem2;
                  _elem2 = iprot.readString();
                  this.to.add(_elem2);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SUBJECT:
            if (field.type == TType.STRING) {
              this.subject = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case DATA:
            if (field.type == TType.STRING) {
              this.data = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SENDER:
            if (field.type == TType.STRING) {
              this.sender = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case ATTACHMENTS:
            if (field.type == TType.LIST) {
              {
                TList _list3 = iprot.readListBegin();
                this.attachments = new ArrayList<String>(_list3.size);
                for (int _i4 = 0; _i4 < _list3.size; ++_i4)
                {
                  String _elem5;
                  _elem5 = iprot.readString();
                  this.attachments.add(_elem5);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case PASSWORD:
            if (field.type == TType.STRING) {
              this.password = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.to != null) {
      oprot.writeFieldBegin(TO_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.to.size()));
        for (String _iter6 : this.to)
        {
          oprot.writeString(_iter6);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.subject != null) {
      oprot.writeFieldBegin(SUBJECT_FIELD_DESC);
      oprot.writeString(this.subject);
      oprot.writeFieldEnd();
    }
    if (this.data != null) {
      oprot.writeFieldBegin(DATA_FIELD_DESC);
      oprot.writeString(this.data);
      oprot.writeFieldEnd();
    }
    if (this.sender != null) {
      oprot.writeFieldBegin(SENDER_FIELD_DESC);
      oprot.writeString(this.sender);
      oprot.writeFieldEnd();
    }
    if (this.attachments != null) {
      oprot.writeFieldBegin(ATTACHMENTS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.attachments.size()));
        for (String _iter7 : this.attachments)
        {
          oprot.writeString(_iter7);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.password != null) {
      oprot.writeFieldBegin(PASSWORD_FIELD_DESC);
      oprot.writeString(this.password);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("to:");
    if (this.to == null) {
      sb.append("null");
    } else {
      sb.append(this.to);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("subject:");
    if (this.subject == null) {
      sb.append("null");
    } else {
      sb.append(this.subject);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("data:");
    if (this.data == null) {
      sb.append("null");
    } else {
      sb.append(this.data);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("sender:");
    if (this.sender == null) {
      sb.append("null");
    } else {
      sb.append(this.sender);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("attachments:");
    if (this.attachments == null) {
      sb.append("null");
    } else {
      sb.append(this.attachments);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("password:");
    if (this.password == null) {
      sb.append("null");
    } else {
      sb.append(this.password);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
  }

}