Subversion Repositories SmartDukaan

Rev

Rev 4496 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift Compiler (0.7.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.purchase;

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;

public class Purchase implements org.apache.thrift.TBase<Purchase, Purchase._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Purchase");

  private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField PO_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("poId", org.apache.thrift.protocol.TType.I64, (short)2);
  private static final org.apache.thrift.protocol.TField INVOICE_NUMBER_FIELD_DESC = new org.apache.thrift.protocol.TField("invoiceNumber", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField RECEIVED_ON_FIELD_DESC = new org.apache.thrift.protocol.TField("receivedOn", org.apache.thrift.protocol.TType.I64, (short)4);
  private static final org.apache.thrift.protocol.TField FREIGHT_CHARGES_FIELD_DESC = new org.apache.thrift.protocol.TField("freightCharges", org.apache.thrift.protocol.TType.DOUBLE, (short)5);
  private static final org.apache.thrift.protocol.TField PURCHASE_COMMENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("purchaseComments", org.apache.thrift.protocol.TType.STRING, (short)6);

  private long id; // required
  private long poId; // required
  private String invoiceNumber; // required
  private long receivedOn; // required
  private double freightCharges; // required
  private String purchaseComments; // 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"),
    PO_ID((short)2, "poId"),
    INVOICE_NUMBER((short)3, "invoiceNumber"),
    RECEIVED_ON((short)4, "receivedOn"),
    FREIGHT_CHARGES((short)5, "freightCharges"),
    PURCHASE_COMMENTS((short)6, "purchaseComments");

    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: // PO_ID
          return PO_ID;
        case 3: // INVOICE_NUMBER
          return INVOICE_NUMBER;
        case 4: // RECEIVED_ON
          return RECEIVED_ON;
        case 5: // FREIGHT_CHARGES
          return FREIGHT_CHARGES;
        case 6: // PURCHASE_COMMENTS
          return PURCHASE_COMMENTS;
        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 __ID_ISSET_ID = 0;
  private static final int __POID_ISSET_ID = 1;
  private static final int __RECEIVEDON_ISSET_ID = 2;
  private static final int __FREIGHTCHARGES_ISSET_ID = 3;
  private BitSet __isset_bit_vector = new BitSet(4);

  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.I64)));
    tmpMap.put(_Fields.PO_ID, new org.apache.thrift.meta_data.FieldMetaData("poId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.INVOICE_NUMBER, new org.apache.thrift.meta_data.FieldMetaData("invoiceNumber", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.RECEIVED_ON, new org.apache.thrift.meta_data.FieldMetaData("receivedOn", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.FREIGHT_CHARGES, new org.apache.thrift.meta_data.FieldMetaData("freightCharges", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    tmpMap.put(_Fields.PURCHASE_COMMENTS, new org.apache.thrift.meta_data.FieldMetaData("purchaseComments", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Purchase.class, metaDataMap);
  }

  public Purchase() {
  }

  public Purchase(
    long id,
    long poId,
    String invoiceNumber,
    long receivedOn,
    double freightCharges,
    String purchaseComments)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.poId = poId;
    setPoIdIsSet(true);
    this.invoiceNumber = invoiceNumber;
    this.receivedOn = receivedOn;
    setReceivedOnIsSet(true);
    this.freightCharges = freightCharges;
    setFreightChargesIsSet(true);
    this.purchaseComments = purchaseComments;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Purchase(Purchase other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    this.poId = other.poId;
    if (other.isSetInvoiceNumber()) {
      this.invoiceNumber = other.invoiceNumber;
    }
    this.receivedOn = other.receivedOn;
    this.freightCharges = other.freightCharges;
    if (other.isSetPurchaseComments()) {
      this.purchaseComments = other.purchaseComments;
    }
  }

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

  @Override
  public void clear() {
    setIdIsSet(false);
    this.id = 0;
    setPoIdIsSet(false);
    this.poId = 0;
    this.invoiceNumber = null;
    setReceivedOnIsSet(false);
    this.receivedOn = 0;
    setFreightChargesIsSet(false);
    this.freightCharges = 0.0;
    this.purchaseComments = null;
  }

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

  public void setId(long id) {
    this.id = id;
    setIdIsSet(true);
  }

  public void unsetId() {
    __isset_bit_vector.clear(__ID_ISSET_ID);
  }

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

  public void setIdIsSet(boolean value) {
    __isset_bit_vector.set(__ID_ISSET_ID, value);
  }

  public long getPoId() {
    return this.poId;
  }

  public void setPoId(long poId) {
    this.poId = poId;
    setPoIdIsSet(true);
  }

  public void unsetPoId() {
    __isset_bit_vector.clear(__POID_ISSET_ID);
  }

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

  public void setPoIdIsSet(boolean value) {
    __isset_bit_vector.set(__POID_ISSET_ID, value);
  }

  public String getInvoiceNumber() {
    return this.invoiceNumber;
  }

  public void setInvoiceNumber(String invoiceNumber) {
    this.invoiceNumber = invoiceNumber;
  }

  public void unsetInvoiceNumber() {
    this.invoiceNumber = null;
  }

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

  public void setInvoiceNumberIsSet(boolean value) {
    if (!value) {
      this.invoiceNumber = null;
    }
  }

  public long getReceivedOn() {
    return this.receivedOn;
  }

  public void setReceivedOn(long receivedOn) {
    this.receivedOn = receivedOn;
    setReceivedOnIsSet(true);
  }

  public void unsetReceivedOn() {
    __isset_bit_vector.clear(__RECEIVEDON_ISSET_ID);
  }

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

  public void setReceivedOnIsSet(boolean value) {
    __isset_bit_vector.set(__RECEIVEDON_ISSET_ID, value);
  }

  public double getFreightCharges() {
    return this.freightCharges;
  }

  public void setFreightCharges(double freightCharges) {
    this.freightCharges = freightCharges;
    setFreightChargesIsSet(true);
  }

  public void unsetFreightCharges() {
    __isset_bit_vector.clear(__FREIGHTCHARGES_ISSET_ID);
  }

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

  public void setFreightChargesIsSet(boolean value) {
    __isset_bit_vector.set(__FREIGHTCHARGES_ISSET_ID, value);
  }

  public String getPurchaseComments() {
    return this.purchaseComments;
  }

  public void setPurchaseComments(String purchaseComments) {
    this.purchaseComments = purchaseComments;
  }

  public void unsetPurchaseComments() {
    this.purchaseComments = null;
  }

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

  public void setPurchaseCommentsIsSet(boolean value) {
    if (!value) {
      this.purchaseComments = null;
    }
  }

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

    case PO_ID:
      if (value == null) {
        unsetPoId();
      } else {
        setPoId((Long)value);
      }
      break;

    case INVOICE_NUMBER:
      if (value == null) {
        unsetInvoiceNumber();
      } else {
        setInvoiceNumber((String)value);
      }
      break;

    case RECEIVED_ON:
      if (value == null) {
        unsetReceivedOn();
      } else {
        setReceivedOn((Long)value);
      }
      break;

    case FREIGHT_CHARGES:
      if (value == null) {
        unsetFreightCharges();
      } else {
        setFreightCharges((Double)value);
      }
      break;

    case PURCHASE_COMMENTS:
      if (value == null) {
        unsetPurchaseComments();
      } else {
        setPurchaseComments((String)value);
      }
      break;

    }
  }

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

    case PO_ID:
      return Long.valueOf(getPoId());

    case INVOICE_NUMBER:
      return getInvoiceNumber();

    case RECEIVED_ON:
      return Long.valueOf(getReceivedOn());

    case FREIGHT_CHARGES:
      return Double.valueOf(getFreightCharges());

    case PURCHASE_COMMENTS:
      return getPurchaseComments();

    }
    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 PO_ID:
      return isSetPoId();
    case INVOICE_NUMBER:
      return isSetInvoiceNumber();
    case RECEIVED_ON:
      return isSetReceivedOn();
    case FREIGHT_CHARGES:
      return isSetFreightCharges();
    case PURCHASE_COMMENTS:
      return isSetPurchaseComments();
    }
    throw new IllegalStateException();
  }

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

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

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

    boolean this_present_poId = true;
    boolean that_present_poId = true;
    if (this_present_poId || that_present_poId) {
      if (!(this_present_poId && that_present_poId))
        return false;
      if (this.poId != that.poId)
        return false;
    }

    boolean this_present_invoiceNumber = true && this.isSetInvoiceNumber();
    boolean that_present_invoiceNumber = true && that.isSetInvoiceNumber();
    if (this_present_invoiceNumber || that_present_invoiceNumber) {
      if (!(this_present_invoiceNumber && that_present_invoiceNumber))
        return false;
      if (!this.invoiceNumber.equals(that.invoiceNumber))
        return false;
    }

    boolean this_present_receivedOn = true;
    boolean that_present_receivedOn = true;
    if (this_present_receivedOn || that_present_receivedOn) {
      if (!(this_present_receivedOn && that_present_receivedOn))
        return false;
      if (this.receivedOn != that.receivedOn)
        return false;
    }

    boolean this_present_freightCharges = true;
    boolean that_present_freightCharges = true;
    if (this_present_freightCharges || that_present_freightCharges) {
      if (!(this_present_freightCharges && that_present_freightCharges))
        return false;
      if (this.freightCharges != that.freightCharges)
        return false;
    }

    boolean this_present_purchaseComments = true && this.isSetPurchaseComments();
    boolean that_present_purchaseComments = true && that.isSetPurchaseComments();
    if (this_present_purchaseComments || that_present_purchaseComments) {
      if (!(this_present_purchaseComments && that_present_purchaseComments))
        return false;
      if (!this.purchaseComments.equals(that.purchaseComments))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetId()).compareTo(typedOther.isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, typedOther.id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPoId()).compareTo(typedOther.isSetPoId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPoId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.poId, typedOther.poId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetInvoiceNumber()).compareTo(typedOther.isSetInvoiceNumber());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetInvoiceNumber()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.invoiceNumber, typedOther.invoiceNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetReceivedOn()).compareTo(typedOther.isSetReceivedOn());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetReceivedOn()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.receivedOn, typedOther.receivedOn);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFreightCharges()).compareTo(typedOther.isSetFreightCharges());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFreightCharges()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.freightCharges, typedOther.freightCharges);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPurchaseComments()).compareTo(typedOther.isSetPurchaseComments());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPurchaseComments()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.purchaseComments, typedOther.purchaseComments);
      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 {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
        break;
      }
      switch (field.id) {
        case 1: // ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.id = iprot.readI64();
            setIdIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // PO_ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.poId = iprot.readI64();
            setPoIdIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // INVOICE_NUMBER
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.invoiceNumber = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // RECEIVED_ON
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.receivedOn = iprot.readI64();
            setReceivedOnIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // FREIGHT_CHARGES
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.freightCharges = iprot.readDouble();
            setFreightChargesIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 6: // PURCHASE_COMMENTS
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.purchaseComments = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(ID_FIELD_DESC);
    oprot.writeI64(this.id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(PO_ID_FIELD_DESC);
    oprot.writeI64(this.poId);
    oprot.writeFieldEnd();
    if (this.invoiceNumber != null) {
      oprot.writeFieldBegin(INVOICE_NUMBER_FIELD_DESC);
      oprot.writeString(this.invoiceNumber);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(RECEIVED_ON_FIELD_DESC);
    oprot.writeI64(this.receivedOn);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(FREIGHT_CHARGES_FIELD_DESC);
    oprot.writeDouble(this.freightCharges);
    oprot.writeFieldEnd();
    if (this.purchaseComments != null) {
      oprot.writeFieldBegin(PURCHASE_COMMENTS_FIELD_DESC);
      oprot.writeString(this.purchaseComments);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("poId:");
    sb.append(this.poId);
    first = false;
    if (!first) sb.append(", ");
    sb.append("invoiceNumber:");
    if (this.invoiceNumber == null) {
      sb.append("null");
    } else {
      sb.append(this.invoiceNumber);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("receivedOn:");
    sb.append(this.receivedOn);
    first = false;
    if (!first) sb.append(", ");
    sb.append("freightCharges:");
    sb.append(this.freightCharges);
    first = false;
    if (!first) sb.append(", ");
    sb.append("purchaseComments:");
    if (this.purchaseComments == null) {
      sb.append("null");
    } else {
      sb.append(this.purchaseComments);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

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

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

}