Subversion Repositories SmartDukaan

Rev

Blame | 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.warehouse;

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.*;

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

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

  private long id;
  private long poId;
  private String invoiceNumber;
  private long receivedOn;
  private double freightCharges;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements 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");

    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
  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, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.PO_ID, new FieldMetaData("poId", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.INVOICE_NUMBER, new FieldMetaData("invoiceNumber", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.RECEIVED_ON, new FieldMetaData("receivedOn", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.FREIGHT_CHARGES, new FieldMetaData("freightCharges", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
  }});

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

  public Purchase() {
  }

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

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

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

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

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

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

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

  /** Returns true if field id is set (has been asigned 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 Purchase setPoId(long poId) {
    this.poId = poId;
    setPoIdIsSet(true);
    return this;
  }

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

  /** Returns true if field poId is set (has been asigned 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 Purchase setInvoiceNumber(String invoiceNumber) {
    this.invoiceNumber = invoiceNumber;
    return this;
  }

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

  /** Returns true if field invoiceNumber is set (has been asigned 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 Purchase setReceivedOn(long receivedOn) {
    this.receivedOn = receivedOn;
    setReceivedOnIsSet(true);
    return this;
  }

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

  /** Returns true if field receivedOn is set (has been asigned 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 Purchase setFreightCharges(double freightCharges) {
    this.freightCharges = freightCharges;
    setFreightChargesIsSet(true);
    return this;
  }

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

  /** Returns true if field freightCharges is set (has been asigned 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 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;

    }
  }

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

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

    case PO_ID:
      return new Long(getPoId());

    case INVOICE_NUMBER:
      return getInvoiceNumber();

    case RECEIVED_ON:
      return new Long(getReceivedOn());

    case FREIGHT_CHARGES:
      return new Double(getFreightCharges());

    }
    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 ID:
      return isSetId();
    case PO_ID:
      return isSetPoId();
    case INVOICE_NUMBER:
      return isSetInvoiceNumber();
    case RECEIVED_ON:
      return isSetReceivedOn();
    case FREIGHT_CHARGES:
      return isSetFreightCharges();
    }
    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 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;
    }

    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(isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetPoId()).compareTo(isSetPoId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(poId, typedOther.poId);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetInvoiceNumber()).compareTo(isSetInvoiceNumber());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(invoiceNumber, typedOther.invoiceNumber);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetReceivedOn()).compareTo(isSetReceivedOn());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(receivedOn, typedOther.receivedOn);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetFreightCharges()).compareTo(isSetFreightCharges());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(freightCharges, typedOther.freightCharges);
    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 ID:
            if (field.type == TType.I64) {
              this.id = iprot.readI64();
              setIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case PO_ID:
            if (field.type == TType.I64) {
              this.poId = iprot.readI64();
              setPoIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case INVOICE_NUMBER:
            if (field.type == TType.STRING) {
              this.invoiceNumber = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case RECEIVED_ON:
            if (field.type == TType.I64) {
              this.receivedOn = iprot.readI64();
              setReceivedOnIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case FREIGHT_CHARGES:
            if (field.type == TType.DOUBLE) {
              this.freightCharges = iprot.readDouble();
              setFreightChargesIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(TProtocol oprot) throws 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();
    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;
    sb.append(")");
    return sb.toString();
  }

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

}