Subversion Repositories SmartDukaan

Rev

Rev 4496 | Rev 9416 | Go to most recent revision | 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 PurchaseOrder implements org.apache.thrift.TBase<PurchaseOrder, PurchaseOrder._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PurchaseOrder");

  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_NUMBER_FIELD_DESC = new org.apache.thrift.protocol.TField("poNumber", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField LINEITEMS_FIELD_DESC = new org.apache.thrift.protocol.TField("lineitems", org.apache.thrift.protocol.TType.LIST, (short)3);
  private static final org.apache.thrift.protocol.TField SUPPLIER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("supplierId", org.apache.thrift.protocol.TType.I64, (short)4);
  private static final org.apache.thrift.protocol.TField WAREHOUSE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("warehouseId", org.apache.thrift.protocol.TType.I64, (short)5);
  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)6);
  private static final org.apache.thrift.protocol.TField CREATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("createdAt", org.apache.thrift.protocol.TType.I64, (short)7);
  private static final org.apache.thrift.protocol.TField UPDATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedAt", org.apache.thrift.protocol.TType.I64, (short)8);
  private static final org.apache.thrift.protocol.TField TOTAL_COST_FIELD_DESC = new org.apache.thrift.protocol.TField("totalCost", org.apache.thrift.protocol.TType.DOUBLE, (short)9);
  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)10);
  private static final org.apache.thrift.protocol.TField REALIZED_COST_FIELD_DESC = new org.apache.thrift.protocol.TField("realizedCost", org.apache.thrift.protocol.TType.DOUBLE, (short)11);
  private static final org.apache.thrift.protocol.TField REALIZED_FREIGHT_CHARGES_FIELD_DESC = new org.apache.thrift.protocol.TField("realizedFreightCharges", org.apache.thrift.protocol.TType.DOUBLE, (short)12);
  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)13);

  private long id; // required
  private String poNumber; // required
  private List<LineItem> lineitems; // required
  private long supplierId; // required
  private long warehouseId; // required
  private POStatus status; // required
  private long createdAt; // required
  private long updatedAt; // required
  private double totalCost; // required
  private double freightCharges; // required
  private double realizedCost; // required
  private double realizedFreightCharges; // required
  private POType type; // 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_NUMBER((short)2, "poNumber"),
    LINEITEMS((short)3, "lineitems"),
    SUPPLIER_ID((short)4, "supplierId"),
    WAREHOUSE_ID((short)5, "warehouseId"),
    /**
     * 
     * @see POStatus
     */
    STATUS((short)6, "status"),
    CREATED_AT((short)7, "createdAt"),
    UPDATED_AT((short)8, "updatedAt"),
    TOTAL_COST((short)9, "totalCost"),
    FREIGHT_CHARGES((short)10, "freightCharges"),
    REALIZED_COST((short)11, "realizedCost"),
    REALIZED_FREIGHT_CHARGES((short)12, "realizedFreightCharges"),
    /**
     * 
     * @see POType
     */
    TYPE((short)13, "type");

    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_NUMBER
          return PO_NUMBER;
        case 3: // LINEITEMS
          return LINEITEMS;
        case 4: // SUPPLIER_ID
          return SUPPLIER_ID;
        case 5: // WAREHOUSE_ID
          return WAREHOUSE_ID;
        case 6: // STATUS
          return STATUS;
        case 7: // CREATED_AT
          return CREATED_AT;
        case 8: // UPDATED_AT
          return UPDATED_AT;
        case 9: // TOTAL_COST
          return TOTAL_COST;
        case 10: // FREIGHT_CHARGES
          return FREIGHT_CHARGES;
        case 11: // REALIZED_COST
          return REALIZED_COST;
        case 12: // REALIZED_FREIGHT_CHARGES
          return REALIZED_FREIGHT_CHARGES;
        case 13: // TYPE
          return TYPE;
        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 __SUPPLIERID_ISSET_ID = 1;
  private static final int __WAREHOUSEID_ISSET_ID = 2;
  private static final int __CREATEDAT_ISSET_ID = 3;
  private static final int __UPDATEDAT_ISSET_ID = 4;
  private static final int __TOTALCOST_ISSET_ID = 5;
  private static final int __FREIGHTCHARGES_ISSET_ID = 6;
  private static final int __REALIZEDCOST_ISSET_ID = 7;
  private static final int __REALIZEDFREIGHTCHARGES_ISSET_ID = 8;
  private BitSet __isset_bit_vector = new BitSet(9);

  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_NUMBER, new org.apache.thrift.meta_data.FieldMetaData("poNumber", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.LINEITEMS, new org.apache.thrift.meta_data.FieldMetaData("lineitems", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, LineItem.class))));
    tmpMap.put(_Fields.SUPPLIER_ID, new org.apache.thrift.meta_data.FieldMetaData("supplierId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.WAREHOUSE_ID, new org.apache.thrift.meta_data.FieldMetaData("warehouseId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, POStatus.class)));
    tmpMap.put(_Fields.CREATED_AT, new org.apache.thrift.meta_data.FieldMetaData("createdAt", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.UPDATED_AT, new org.apache.thrift.meta_data.FieldMetaData("updatedAt", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.TOTAL_COST, new org.apache.thrift.meta_data.FieldMetaData("totalCost", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    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.REALIZED_COST, new org.apache.thrift.meta_data.FieldMetaData("realizedCost", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    tmpMap.put(_Fields.REALIZED_FREIGHT_CHARGES, new org.apache.thrift.meta_data.FieldMetaData("realizedFreightCharges", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, POType.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PurchaseOrder.class, metaDataMap);
  }

  public PurchaseOrder() {
  }

  public PurchaseOrder(
    long id,
    String poNumber,
    List<LineItem> lineitems,
    long supplierId,
    long warehouseId,
    POStatus status,
    long createdAt,
    long updatedAt,
    double totalCost,
    double freightCharges,
    double realizedCost,
    double realizedFreightCharges,
    POType type)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.poNumber = poNumber;
    this.lineitems = lineitems;
    this.supplierId = supplierId;
    setSupplierIdIsSet(true);
    this.warehouseId = warehouseId;
    setWarehouseIdIsSet(true);
    this.status = status;
    this.createdAt = createdAt;
    setCreatedAtIsSet(true);
    this.updatedAt = updatedAt;
    setUpdatedAtIsSet(true);
    this.totalCost = totalCost;
    setTotalCostIsSet(true);
    this.freightCharges = freightCharges;
    setFreightChargesIsSet(true);
    this.realizedCost = realizedCost;
    setRealizedCostIsSet(true);
    this.realizedFreightCharges = realizedFreightCharges;
    setRealizedFreightChargesIsSet(true);
    this.type = type;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public PurchaseOrder(PurchaseOrder other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetPoNumber()) {
      this.poNumber = other.poNumber;
    }
    if (other.isSetLineitems()) {
      List<LineItem> __this__lineitems = new ArrayList<LineItem>();
      for (LineItem other_element : other.lineitems) {
        __this__lineitems.add(new LineItem(other_element));
      }
      this.lineitems = __this__lineitems;
    }
    this.supplierId = other.supplierId;
    this.warehouseId = other.warehouseId;
    if (other.isSetStatus()) {
      this.status = other.status;
    }
    this.createdAt = other.createdAt;
    this.updatedAt = other.updatedAt;
    this.totalCost = other.totalCost;
    this.freightCharges = other.freightCharges;
    this.realizedCost = other.realizedCost;
    this.realizedFreightCharges = other.realizedFreightCharges;
    if (other.isSetType()) {
      this.type = other.type;
    }
  }

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

  @Override
  public void clear() {
    setIdIsSet(false);
    this.id = 0;
    this.poNumber = null;
    this.lineitems = null;
    setSupplierIdIsSet(false);
    this.supplierId = 0;
    setWarehouseIdIsSet(false);
    this.warehouseId = 0;
    this.status = null;
    setCreatedAtIsSet(false);
    this.createdAt = 0;
    setUpdatedAtIsSet(false);
    this.updatedAt = 0;
    setTotalCostIsSet(false);
    this.totalCost = 0.0;
    setFreightChargesIsSet(false);
    this.freightCharges = 0.0;
    setRealizedCostIsSet(false);
    this.realizedCost = 0.0;
    setRealizedFreightChargesIsSet(false);
    this.realizedFreightCharges = 0.0;
    this.type = 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 String getPoNumber() {
    return this.poNumber;
  }

  public void setPoNumber(String poNumber) {
    this.poNumber = poNumber;
  }

  public void unsetPoNumber() {
    this.poNumber = null;
  }

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

  public void setPoNumberIsSet(boolean value) {
    if (!value) {
      this.poNumber = null;
    }
  }

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

  public java.util.Iterator<LineItem> getLineitemsIterator() {
    return (this.lineitems == null) ? null : this.lineitems.iterator();
  }

  public void addToLineitems(LineItem elem) {
    if (this.lineitems == null) {
      this.lineitems = new ArrayList<LineItem>();
    }
    this.lineitems.add(elem);
  }

  public List<LineItem> getLineitems() {
    return this.lineitems;
  }

  public void setLineitems(List<LineItem> lineitems) {
    this.lineitems = lineitems;
  }

  public void unsetLineitems() {
    this.lineitems = null;
  }

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

  public void setLineitemsIsSet(boolean value) {
    if (!value) {
      this.lineitems = null;
    }
  }

  public long getSupplierId() {
    return this.supplierId;
  }

  public void setSupplierId(long supplierId) {
    this.supplierId = supplierId;
    setSupplierIdIsSet(true);
  }

  public void unsetSupplierId() {
    __isset_bit_vector.clear(__SUPPLIERID_ISSET_ID);
  }

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

  public void setSupplierIdIsSet(boolean value) {
    __isset_bit_vector.set(__SUPPLIERID_ISSET_ID, value);
  }

  public long getWarehouseId() {
    return this.warehouseId;
  }

  public void setWarehouseId(long warehouseId) {
    this.warehouseId = warehouseId;
    setWarehouseIdIsSet(true);
  }

  public void unsetWarehouseId() {
    __isset_bit_vector.clear(__WAREHOUSEID_ISSET_ID);
  }

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

  public void setWarehouseIdIsSet(boolean value) {
    __isset_bit_vector.set(__WAREHOUSEID_ISSET_ID, value);
  }

  /**
   * 
   * @see POStatus
   */
  public POStatus getStatus() {
    return this.status;
  }

  /**
   * 
   * @see POStatus
   */
  public void setStatus(POStatus status) {
    this.status = status;
  }

  public void unsetStatus() {
    this.status = null;
  }

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

  public void setStatusIsSet(boolean value) {
    if (!value) {
      this.status = null;
    }
  }

  public long getCreatedAt() {
    return this.createdAt;
  }

  public void setCreatedAt(long createdAt) {
    this.createdAt = createdAt;
    setCreatedAtIsSet(true);
  }

  public void unsetCreatedAt() {
    __isset_bit_vector.clear(__CREATEDAT_ISSET_ID);
  }

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

  public void setCreatedAtIsSet(boolean value) {
    __isset_bit_vector.set(__CREATEDAT_ISSET_ID, value);
  }

  public long getUpdatedAt() {
    return this.updatedAt;
  }

  public void setUpdatedAt(long updatedAt) {
    this.updatedAt = updatedAt;
    setUpdatedAtIsSet(true);
  }

  public void unsetUpdatedAt() {
    __isset_bit_vector.clear(__UPDATEDAT_ISSET_ID);
  }

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

  public void setUpdatedAtIsSet(boolean value) {
    __isset_bit_vector.set(__UPDATEDAT_ISSET_ID, value);
  }

  public double getTotalCost() {
    return this.totalCost;
  }

  public void setTotalCost(double totalCost) {
    this.totalCost = totalCost;
    setTotalCostIsSet(true);
  }

  public void unsetTotalCost() {
    __isset_bit_vector.clear(__TOTALCOST_ISSET_ID);
  }

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

  public void setTotalCostIsSet(boolean value) {
    __isset_bit_vector.set(__TOTALCOST_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 double getRealizedCost() {
    return this.realizedCost;
  }

  public void setRealizedCost(double realizedCost) {
    this.realizedCost = realizedCost;
    setRealizedCostIsSet(true);
  }

  public void unsetRealizedCost() {
    __isset_bit_vector.clear(__REALIZEDCOST_ISSET_ID);
  }

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

  public void setRealizedCostIsSet(boolean value) {
    __isset_bit_vector.set(__REALIZEDCOST_ISSET_ID, value);
  }

  public double getRealizedFreightCharges() {
    return this.realizedFreightCharges;
  }

  public void setRealizedFreightCharges(double realizedFreightCharges) {
    this.realizedFreightCharges = realizedFreightCharges;
    setRealizedFreightChargesIsSet(true);
  }

  public void unsetRealizedFreightCharges() {
    __isset_bit_vector.clear(__REALIZEDFREIGHTCHARGES_ISSET_ID);
  }

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

  public void setRealizedFreightChargesIsSet(boolean value) {
    __isset_bit_vector.set(__REALIZEDFREIGHTCHARGES_ISSET_ID, value);
  }

  /**
   * 
   * @see POType
   */
  public POType getType() {
    return this.type;
  }

  /**
   * 
   * @see POType
   */
  public void setType(POType type) {
    this.type = type;
  }

  public void unsetType() {
    this.type = null;
  }

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

  public void setTypeIsSet(boolean value) {
    if (!value) {
      this.type = null;
    }
  }

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

    case PO_NUMBER:
      if (value == null) {
        unsetPoNumber();
      } else {
        setPoNumber((String)value);
      }
      break;

    case LINEITEMS:
      if (value == null) {
        unsetLineitems();
      } else {
        setLineitems((List<LineItem>)value);
      }
      break;

    case SUPPLIER_ID:
      if (value == null) {
        unsetSupplierId();
      } else {
        setSupplierId((Long)value);
      }
      break;

    case WAREHOUSE_ID:
      if (value == null) {
        unsetWarehouseId();
      } else {
        setWarehouseId((Long)value);
      }
      break;

    case STATUS:
      if (value == null) {
        unsetStatus();
      } else {
        setStatus((POStatus)value);
      }
      break;

    case CREATED_AT:
      if (value == null) {
        unsetCreatedAt();
      } else {
        setCreatedAt((Long)value);
      }
      break;

    case UPDATED_AT:
      if (value == null) {
        unsetUpdatedAt();
      } else {
        setUpdatedAt((Long)value);
      }
      break;

    case TOTAL_COST:
      if (value == null) {
        unsetTotalCost();
      } else {
        setTotalCost((Double)value);
      }
      break;

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

    case REALIZED_COST:
      if (value == null) {
        unsetRealizedCost();
      } else {
        setRealizedCost((Double)value);
      }
      break;

    case REALIZED_FREIGHT_CHARGES:
      if (value == null) {
        unsetRealizedFreightCharges();
      } else {
        setRealizedFreightCharges((Double)value);
      }
      break;

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

    }
  }

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

    case PO_NUMBER:
      return getPoNumber();

    case LINEITEMS:
      return getLineitems();

    case SUPPLIER_ID:
      return Long.valueOf(getSupplierId());

    case WAREHOUSE_ID:
      return Long.valueOf(getWarehouseId());

    case STATUS:
      return getStatus();

    case CREATED_AT:
      return Long.valueOf(getCreatedAt());

    case UPDATED_AT:
      return Long.valueOf(getUpdatedAt());

    case TOTAL_COST:
      return Double.valueOf(getTotalCost());

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

    case REALIZED_COST:
      return Double.valueOf(getRealizedCost());

    case REALIZED_FREIGHT_CHARGES:
      return Double.valueOf(getRealizedFreightCharges());

    case TYPE:
      return getType();

    }
    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_NUMBER:
      return isSetPoNumber();
    case LINEITEMS:
      return isSetLineitems();
    case SUPPLIER_ID:
      return isSetSupplierId();
    case WAREHOUSE_ID:
      return isSetWarehouseId();
    case STATUS:
      return isSetStatus();
    case CREATED_AT:
      return isSetCreatedAt();
    case UPDATED_AT:
      return isSetUpdatedAt();
    case TOTAL_COST:
      return isSetTotalCost();
    case FREIGHT_CHARGES:
      return isSetFreightCharges();
    case REALIZED_COST:
      return isSetRealizedCost();
    case REALIZED_FREIGHT_CHARGES:
      return isSetRealizedFreightCharges();
    case TYPE:
      return isSetType();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(PurchaseOrder 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_poNumber = true && this.isSetPoNumber();
    boolean that_present_poNumber = true && that.isSetPoNumber();
    if (this_present_poNumber || that_present_poNumber) {
      if (!(this_present_poNumber && that_present_poNumber))
        return false;
      if (!this.poNumber.equals(that.poNumber))
        return false;
    }

    boolean this_present_lineitems = true && this.isSetLineitems();
    boolean that_present_lineitems = true && that.isSetLineitems();
    if (this_present_lineitems || that_present_lineitems) {
      if (!(this_present_lineitems && that_present_lineitems))
        return false;
      if (!this.lineitems.equals(that.lineitems))
        return false;
    }

    boolean this_present_supplierId = true;
    boolean that_present_supplierId = true;
    if (this_present_supplierId || that_present_supplierId) {
      if (!(this_present_supplierId && that_present_supplierId))
        return false;
      if (this.supplierId != that.supplierId)
        return false;
    }

    boolean this_present_warehouseId = true;
    boolean that_present_warehouseId = true;
    if (this_present_warehouseId || that_present_warehouseId) {
      if (!(this_present_warehouseId && that_present_warehouseId))
        return false;
      if (this.warehouseId != that.warehouseId)
        return false;
    }

    boolean this_present_status = true && this.isSetStatus();
    boolean that_present_status = true && that.isSetStatus();
    if (this_present_status || that_present_status) {
      if (!(this_present_status && that_present_status))
        return false;
      if (!this.status.equals(that.status))
        return false;
    }

    boolean this_present_createdAt = true;
    boolean that_present_createdAt = true;
    if (this_present_createdAt || that_present_createdAt) {
      if (!(this_present_createdAt && that_present_createdAt))
        return false;
      if (this.createdAt != that.createdAt)
        return false;
    }

    boolean this_present_updatedAt = true;
    boolean that_present_updatedAt = true;
    if (this_present_updatedAt || that_present_updatedAt) {
      if (!(this_present_updatedAt && that_present_updatedAt))
        return false;
      if (this.updatedAt != that.updatedAt)
        return false;
    }

    boolean this_present_totalCost = true;
    boolean that_present_totalCost = true;
    if (this_present_totalCost || that_present_totalCost) {
      if (!(this_present_totalCost && that_present_totalCost))
        return false;
      if (this.totalCost != that.totalCost)
        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_realizedCost = true;
    boolean that_present_realizedCost = true;
    if (this_present_realizedCost || that_present_realizedCost) {
      if (!(this_present_realizedCost && that_present_realizedCost))
        return false;
      if (this.realizedCost != that.realizedCost)
        return false;
    }

    boolean this_present_realizedFreightCharges = true;
    boolean that_present_realizedFreightCharges = true;
    if (this_present_realizedFreightCharges || that_present_realizedFreightCharges) {
      if (!(this_present_realizedFreightCharges && that_present_realizedFreightCharges))
        return false;
      if (this.realizedFreightCharges != that.realizedFreightCharges)
        return false;
    }

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

    return true;
  }

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

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

    int lastComparison = 0;
    PurchaseOrder typedOther = (PurchaseOrder)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(isSetPoNumber()).compareTo(typedOther.isSetPoNumber());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPoNumber()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.poNumber, typedOther.poNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetLineitems()).compareTo(typedOther.isSetLineitems());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLineitems()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lineitems, typedOther.lineitems);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetSupplierId()).compareTo(typedOther.isSetSupplierId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSupplierId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.supplierId, typedOther.supplierId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetWarehouseId()).compareTo(typedOther.isSetWarehouseId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetWarehouseId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.warehouseId, typedOther.warehouseId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStatus()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetCreatedAt()).compareTo(typedOther.isSetCreatedAt());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCreatedAt()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdAt, typedOther.createdAt);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetUpdatedAt()).compareTo(typedOther.isSetUpdatedAt());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetUpdatedAt()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedAt, typedOther.updatedAt);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetTotalCost()).compareTo(typedOther.isSetTotalCost());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTotalCost()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.totalCost, typedOther.totalCost);
      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(isSetRealizedCost()).compareTo(typedOther.isSetRealizedCost());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRealizedCost()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.realizedCost, typedOther.realizedCost);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRealizedFreightCharges()).compareTo(typedOther.isSetRealizedFreightCharges());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRealizedFreightCharges()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.realizedFreightCharges, typedOther.realizedFreightCharges);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type);
      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_NUMBER
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.poNumber = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // LINEITEMS
          if (field.type == org.apache.thrift.protocol.TType.LIST) {
            {
              org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
              this.lineitems = new ArrayList<LineItem>(_list0.size);
              for (int _i1 = 0; _i1 < _list0.size; ++_i1)
              {
                LineItem _elem2; // required
                _elem2 = new LineItem();
                _elem2.read(iprot);
                this.lineitems.add(_elem2);
              }
              iprot.readListEnd();
            }
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // SUPPLIER_ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.supplierId = iprot.readI64();
            setSupplierIdIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // WAREHOUSE_ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.warehouseId = iprot.readI64();
            setWarehouseIdIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 6: // STATUS
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.status = POStatus.findByValue(iprot.readI32());
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 7: // CREATED_AT
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.createdAt = iprot.readI64();
            setCreatedAtIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 8: // UPDATED_AT
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.updatedAt = iprot.readI64();
            setUpdatedAtIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 9: // TOTAL_COST
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.totalCost = iprot.readDouble();
            setTotalCostIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 10: // 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 11: // REALIZED_COST
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.realizedCost = iprot.readDouble();
            setRealizedCostIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 12: // REALIZED_FREIGHT_CHARGES
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.realizedFreightCharges = iprot.readDouble();
            setRealizedFreightChargesIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 13: // TYPE
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.type = POType.findByValue(iprot.readI32());
          } 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();
    if (this.poNumber != null) {
      oprot.writeFieldBegin(PO_NUMBER_FIELD_DESC);
      oprot.writeString(this.poNumber);
      oprot.writeFieldEnd();
    }
    if (this.lineitems != null) {
      oprot.writeFieldBegin(LINEITEMS_FIELD_DESC);
      {
        oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.lineitems.size()));
        for (LineItem _iter3 : this.lineitems)
        {
          _iter3.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(SUPPLIER_ID_FIELD_DESC);
    oprot.writeI64(this.supplierId);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(WAREHOUSE_ID_FIELD_DESC);
    oprot.writeI64(this.warehouseId);
    oprot.writeFieldEnd();
    if (this.status != null) {
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
      oprot.writeI32(this.status.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(CREATED_AT_FIELD_DESC);
    oprot.writeI64(this.createdAt);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(UPDATED_AT_FIELD_DESC);
    oprot.writeI64(this.updatedAt);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(TOTAL_COST_FIELD_DESC);
    oprot.writeDouble(this.totalCost);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(FREIGHT_CHARGES_FIELD_DESC);
    oprot.writeDouble(this.freightCharges);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(REALIZED_COST_FIELD_DESC);
    oprot.writeDouble(this.realizedCost);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(REALIZED_FREIGHT_CHARGES_FIELD_DESC);
    oprot.writeDouble(this.realizedFreightCharges);
    oprot.writeFieldEnd();
    if (this.type != null) {
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
      oprot.writeI32(this.type.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("poNumber:");
    if (this.poNumber == null) {
      sb.append("null");
    } else {
      sb.append(this.poNumber);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("lineitems:");
    if (this.lineitems == null) {
      sb.append("null");
    } else {
      sb.append(this.lineitems);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("supplierId:");
    sb.append(this.supplierId);
    first = false;
    if (!first) sb.append(", ");
    sb.append("warehouseId:");
    sb.append(this.warehouseId);
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      sb.append(this.status);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("createdAt:");
    sb.append(this.createdAt);
    first = false;
    if (!first) sb.append(", ");
    sb.append("updatedAt:");
    sb.append(this.updatedAt);
    first = false;
    if (!first) sb.append(", ");
    sb.append("totalCost:");
    sb.append(this.totalCost);
    first = false;
    if (!first) sb.append(", ");
    sb.append("freightCharges:");
    sb.append(this.freightCharges);
    first = false;
    if (!first) sb.append(", ");
    sb.append("realizedCost:");
    sb.append(this.realizedCost);
    first = false;
    if (!first) sb.append(", ");
    sb.append("realizedFreightCharges:");
    sb.append(this.realizedFreightCharges);
    first = false;
    if (!first) sb.append(", ");
    sb.append("type:");
    if (this.type == null) {
      sb.append("null");
    } else {
      sb.append(this.type);
    }
    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);
    }
  }

}