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 PurchaseOrder implements TBase<PurchaseOrder._Fields>, java.io.Serializable, Cloneable, Comparable<PurchaseOrder> {
  private static final TStruct STRUCT_DESC = new TStruct("PurchaseOrder");

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField PO_NUMBER_FIELD_DESC = new TField("poNumber", TType.STRING, (short)2);
  private static final TField LINEITEMS_FIELD_DESC = new TField("lineitems", TType.LIST, (short)3);
  private static final TField SUPPLIER_ID_FIELD_DESC = new TField("supplierId", TType.I64, (short)4);
  private static final TField WAREHOUSE_ID_FIELD_DESC = new TField("warehouseId", TType.I64, (short)5);
  private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)6);
  private static final TField CREATED_AT_FIELD_DESC = new TField("createdAt", TType.I64, (short)7);
  private static final TField UPDATED_AT_FIELD_DESC = new TField("updatedAt", TType.I64, (short)8);
  private static final TField TOTAL_COST_FIELD_DESC = new TField("totalCost", TType.DOUBLE, (short)9);
  private static final TField FREIGHT_CHARGES_FIELD_DESC = new TField("freightCharges", TType.DOUBLE, (short)10);
  private static final TField REALIZED_COST_FIELD_DESC = new TField("realizedCost", TType.DOUBLE, (short)11);
  private static final TField REALIZED_FREIGHT_CHARGES_FIELD_DESC = new TField("realizedFreightCharges", TType.DOUBLE, (short)12);

  private long id;
  private String poNumber;
  private List<LineItem> lineitems;
  private long supplierId;
  private long warehouseId;
  private POStatus status;
  private long createdAt;
  private long updatedAt;
  private double totalCost;
  private double freightCharges;
  private double realizedCost;
  private double realizedFreightCharges;

  /** 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_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");

    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 __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, 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_NUMBER, new FieldMetaData("poNumber", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.LINEITEMS, new FieldMetaData("lineitems", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, LineItem.class))));
    put(_Fields.SUPPLIER_ID, new FieldMetaData("supplierId", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.WAREHOUSE_ID, new FieldMetaData("warehouseId", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, POStatus.class)));
    put(_Fields.CREATED_AT, new FieldMetaData("createdAt", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.UPDATED_AT, new FieldMetaData("updatedAt", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.TOTAL_COST, new FieldMetaData("totalCost", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.FREIGHT_CHARGES, new FieldMetaData("freightCharges", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.REALIZED_COST, new FieldMetaData("realizedCost", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.REALIZED_FREIGHT_CHARGES, new FieldMetaData("realizedFreightCharges", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
  }});

  static {
    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)
  {
    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);
  }

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

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

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

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

  public PurchaseOrder 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 String getPoNumber() {
    return this.poNumber;
  }

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

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

  /** Returns true if field poNumber is set (has been asigned 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 PurchaseOrder setLineitems(List<LineItem> lineitems) {
    this.lineitems = lineitems;
    return this;
  }

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

  /** Returns true if field lineitems is set (has been asigned 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 PurchaseOrder setSupplierId(long supplierId) {
    this.supplierId = supplierId;
    setSupplierIdIsSet(true);
    return this;
  }

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

  /** Returns true if field supplierId is set (has been asigned 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 PurchaseOrder setWarehouseId(long warehouseId) {
    this.warehouseId = warehouseId;
    setWarehouseIdIsSet(true);
    return this;
  }

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

  /** Returns true if field warehouseId is set (has been asigned 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 PurchaseOrder setStatus(POStatus status) {
    this.status = status;
    return this;
  }

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

  /** Returns true if field status is set (has been asigned 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 PurchaseOrder setCreatedAt(long createdAt) {
    this.createdAt = createdAt;
    setCreatedAtIsSet(true);
    return this;
  }

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

  /** Returns true if field createdAt is set (has been asigned 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 PurchaseOrder setUpdatedAt(long updatedAt) {
    this.updatedAt = updatedAt;
    setUpdatedAtIsSet(true);
    return this;
  }

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

  /** Returns true if field updatedAt is set (has been asigned 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 PurchaseOrder setTotalCost(double totalCost) {
    this.totalCost = totalCost;
    setTotalCostIsSet(true);
    return this;
  }

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

  /** Returns true if field totalCost is set (has been asigned 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 PurchaseOrder 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 double getRealizedCost() {
    return this.realizedCost;
  }

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

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

  /** Returns true if field realizedCost is set (has been asigned 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 PurchaseOrder setRealizedFreightCharges(double realizedFreightCharges) {
    this.realizedFreightCharges = realizedFreightCharges;
    setRealizedFreightChargesIsSet(true);
    return this;
  }

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

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

  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;

    }
  }

  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_NUMBER:
      return getPoNumber();

    case LINEITEMS:
      return getLineitems();

    case SUPPLIER_ID:
      return new Long(getSupplierId());

    case WAREHOUSE_ID:
      return new Long(getWarehouseId());

    case STATUS:
      return getStatus();

    case CREATED_AT:
      return new Long(getCreatedAt());

    case UPDATED_AT:
      return new Long(getUpdatedAt());

    case TOTAL_COST:
      return new Double(getTotalCost());

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

    case REALIZED_COST:
      return new Double(getRealizedCost());

    case REALIZED_FREIGHT_CHARGES:
      return new Double(getRealizedFreightCharges());

    }
    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_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();
    }
    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 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;
    }

    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(isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetPoNumber()).compareTo(isSetPoNumber());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(poNumber, typedOther.poNumber);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetLineitems()).compareTo(isSetLineitems());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(lineitems, typedOther.lineitems);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSupplierId()).compareTo(isSetSupplierId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(supplierId, typedOther.supplierId);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetWarehouseId()).compareTo(isSetWarehouseId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(warehouseId, typedOther.warehouseId);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(status, typedOther.status);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCreatedAt()).compareTo(isSetCreatedAt());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(createdAt, typedOther.createdAt);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetUpdatedAt()).compareTo(isSetUpdatedAt());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(updatedAt, typedOther.updatedAt);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetTotalCost()).compareTo(isSetTotalCost());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(totalCost, typedOther.totalCost);
    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;
    }
    lastComparison = Boolean.valueOf(isSetRealizedCost()).compareTo(isSetRealizedCost());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(realizedCost, typedOther.realizedCost);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetRealizedFreightCharges()).compareTo(isSetRealizedFreightCharges());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(realizedFreightCharges, typedOther.realizedFreightCharges);
    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_NUMBER:
            if (field.type == TType.STRING) {
              this.poNumber = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case LINEITEMS:
            if (field.type == TType.LIST) {
              {
                TList _list0 = iprot.readListBegin();
                this.lineitems = new ArrayList<LineItem>(_list0.size);
                for (int _i1 = 0; _i1 < _list0.size; ++_i1)
                {
                  LineItem _elem2;
                  _elem2 = new LineItem();
                  _elem2.read(iprot);
                  this.lineitems.add(_elem2);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SUPPLIER_ID:
            if (field.type == TType.I64) {
              this.supplierId = iprot.readI64();
              setSupplierIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case WAREHOUSE_ID:
            if (field.type == TType.I64) {
              this.warehouseId = iprot.readI64();
              setWarehouseIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case STATUS:
            if (field.type == TType.I32) {
              this.status = POStatus.findByValue(iprot.readI32());
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CREATED_AT:
            if (field.type == TType.I64) {
              this.createdAt = iprot.readI64();
              setCreatedAtIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case UPDATED_AT:
            if (field.type == TType.I64) {
              this.updatedAt = iprot.readI64();
              setUpdatedAtIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case TOTAL_COST:
            if (field.type == TType.DOUBLE) {
              this.totalCost = iprot.readDouble();
              setTotalCostIsSet(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;
          case REALIZED_COST:
            if (field.type == TType.DOUBLE) {
              this.realizedCost = iprot.readDouble();
              setRealizedCostIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case REALIZED_FREIGHT_CHARGES:
            if (field.type == TType.DOUBLE) {
              this.realizedFreightCharges = iprot.readDouble();
              setRealizedFreightChargesIsSet(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();
    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 TList(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();
    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 {
      String status_name = status.name();
      if (status_name != null) {
        sb.append(status_name);
        sb.append(" (");
      }
      sb.append(this.status);
      if (status_name != null) {
        sb.append(")");
      }
    }
    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;
    sb.append(")");
    return sb.toString();
  }

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

}