Subversion Repositories SmartDukaan

Rev

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

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.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 WarehouseService {

  public interface Iface extends in.shop2020.generic.GenericService.Iface {

    /**
     * Creates a purchase order based on the data in the given purchase order object.
     * This method populates a nummber of missing fields
     * 
     * @param purchaseOrder
     */
    public long createPurchaseOrder(PurchaseOrder purchaseOrder) throws WarehouseServiceException, TException;

    /**
     * Returns the purchase order with the given id. Throws an exception if there is no such purchase order.
     * 
     * @param id
     */
    public PurchaseOrder getPurchaseOrder(long id) throws WarehouseServiceException, TException;

    /**
     * Returns a list of all the purchase orders in the given state
     * 
     * @param status
     */
    public List<PurchaseOrder> getAllPurchaseOrders(POStatus status) throws WarehouseServiceException, TException;

    /**
     * Returns the supplier with the given order id. Throws an exception if there is no such supplier.
     * 
     * @param id
     */
    public Supplier getSupplier(long id) throws WarehouseServiceException, TException;

    /**
     * Creates a purchase for the given purchase order.
     * Throws an exception if no more purchases are allowed against the given purchase order.
     * 
     * @param purchaseOrderId
     * @param invoiceNumber
     * @param freightCharges
     */
    public long startPurchase(long purchaseOrderId, String invoiceNumber, double freightCharges) throws WarehouseServiceException, TException;

    /**
     * Marks a purchase as complete and updates the receivedOn time.
     * Throws an exception if no such purchase exists.
     * 
     * @param purchaseId
     */
    public long closePurchase(long purchaseId) throws WarehouseServiceException, TException;

    /**
     * Returns all open or closed purchases for the given purchase order. Throws an exception if no such purchase order exists
     * 
     * @param purchaseOrderId
     * @param open
     */
    public List<Purchase> getAllPurchases(long purchaseOrderId, boolean open) throws WarehouseServiceException, TException;

    /**
     * Creates a Scan object using the given details.
     * Raises an exception if no more of the given item can be scanned in against the purchase order of the given purchase.
     * 
     * @param purchaseId
     * @param itemNumber
     * @param imeiNumber
     * @param type
     */
    public void scanIn(long purchaseId, String itemNumber, String imeiNumber, ScanType type) throws WarehouseServiceException, TException;

    /**
     * Marks the Scan object with the given details as scanned out. In case, the imeiNumber is not given,
     * marks the oldest ItemInventory object as being scanned out.
     * Raises an exception if:
     * 1. There is no stock present corresponding to the given item details.
     * 2. An older stock is present corresponding to the itemNumber which has not been scanned out.
     * 
     * @param itemNumber
     * @param imeiNumber
     * @param type
     */
    public void scanOut(long itemNumber, long imeiNumber, ScanType type) throws WarehouseServiceException, TException;

  }

  public static class Client extends in.shop2020.generic.GenericService.Client implements Iface {
    public Client(TProtocol prot)
    {
      this(prot, prot);
    }

    public Client(TProtocol iprot, TProtocol oprot)
    {
      super(iprot, oprot);
    }

    public long createPurchaseOrder(PurchaseOrder purchaseOrder) throws WarehouseServiceException, TException
    {
      send_createPurchaseOrder(purchaseOrder);
      return recv_createPurchaseOrder();
    }

    public void send_createPurchaseOrder(PurchaseOrder purchaseOrder) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("createPurchaseOrder", TMessageType.CALL, seqid_));
      createPurchaseOrder_args args = new createPurchaseOrder_args();
      args.purchaseOrder = purchaseOrder;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public long recv_createPurchaseOrder() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      createPurchaseOrder_result result = new createPurchaseOrder_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "createPurchaseOrder failed: unknown result");
    }

    public PurchaseOrder getPurchaseOrder(long id) throws WarehouseServiceException, TException
    {
      send_getPurchaseOrder(id);
      return recv_getPurchaseOrder();
    }

    public void send_getPurchaseOrder(long id) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPurchaseOrder", TMessageType.CALL, seqid_));
      getPurchaseOrder_args args = new getPurchaseOrder_args();
      args.id = id;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public PurchaseOrder recv_getPurchaseOrder() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPurchaseOrder_result result = new getPurchaseOrder_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPurchaseOrder failed: unknown result");
    }

    public List<PurchaseOrder> getAllPurchaseOrders(POStatus status) throws WarehouseServiceException, TException
    {
      send_getAllPurchaseOrders(status);
      return recv_getAllPurchaseOrders();
    }

    public void send_getAllPurchaseOrders(POStatus status) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getAllPurchaseOrders", TMessageType.CALL, seqid_));
      getAllPurchaseOrders_args args = new getAllPurchaseOrders_args();
      args.status = status;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<PurchaseOrder> recv_getAllPurchaseOrders() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getAllPurchaseOrders_result result = new getAllPurchaseOrders_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getAllPurchaseOrders failed: unknown result");
    }

    public Supplier getSupplier(long id) throws WarehouseServiceException, TException
    {
      send_getSupplier(id);
      return recv_getSupplier();
    }

    public void send_getSupplier(long id) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getSupplier", TMessageType.CALL, seqid_));
      getSupplier_args args = new getSupplier_args();
      args.id = id;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public Supplier recv_getSupplier() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getSupplier_result result = new getSupplier_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getSupplier failed: unknown result");
    }

    public long startPurchase(long purchaseOrderId, String invoiceNumber, double freightCharges) throws WarehouseServiceException, TException
    {
      send_startPurchase(purchaseOrderId, invoiceNumber, freightCharges);
      return recv_startPurchase();
    }

    public void send_startPurchase(long purchaseOrderId, String invoiceNumber, double freightCharges) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("startPurchase", TMessageType.CALL, seqid_));
      startPurchase_args args = new startPurchase_args();
      args.purchaseOrderId = purchaseOrderId;
      args.invoiceNumber = invoiceNumber;
      args.freightCharges = freightCharges;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public long recv_startPurchase() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      startPurchase_result result = new startPurchase_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "startPurchase failed: unknown result");
    }

    public long closePurchase(long purchaseId) throws WarehouseServiceException, TException
    {
      send_closePurchase(purchaseId);
      return recv_closePurchase();
    }

    public void send_closePurchase(long purchaseId) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("closePurchase", TMessageType.CALL, seqid_));
      closePurchase_args args = new closePurchase_args();
      args.purchaseId = purchaseId;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public long recv_closePurchase() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      closePurchase_result result = new closePurchase_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "closePurchase failed: unknown result");
    }

    public List<Purchase> getAllPurchases(long purchaseOrderId, boolean open) throws WarehouseServiceException, TException
    {
      send_getAllPurchases(purchaseOrderId, open);
      return recv_getAllPurchases();
    }

    public void send_getAllPurchases(long purchaseOrderId, boolean open) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getAllPurchases", TMessageType.CALL, seqid_));
      getAllPurchases_args args = new getAllPurchases_args();
      args.purchaseOrderId = purchaseOrderId;
      args.open = open;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<Purchase> recv_getAllPurchases() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getAllPurchases_result result = new getAllPurchases_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.wex != null) {
        throw result.wex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getAllPurchases failed: unknown result");
    }

    public void scanIn(long purchaseId, String itemNumber, String imeiNumber, ScanType type) throws WarehouseServiceException, TException
    {
      send_scanIn(purchaseId, itemNumber, imeiNumber, type);
      recv_scanIn();
    }

    public void send_scanIn(long purchaseId, String itemNumber, String imeiNumber, ScanType type) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("scanIn", TMessageType.CALL, seqid_));
      scanIn_args args = new scanIn_args();
      args.purchaseId = purchaseId;
      args.itemNumber = itemNumber;
      args.imeiNumber = imeiNumber;
      args.type = type;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_scanIn() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      scanIn_result result = new scanIn_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.wex != null) {
        throw result.wex;
      }
      return;
    }

    public void scanOut(long itemNumber, long imeiNumber, ScanType type) throws WarehouseServiceException, TException
    {
      send_scanOut(itemNumber, imeiNumber, type);
      recv_scanOut();
    }

    public void send_scanOut(long itemNumber, long imeiNumber, ScanType type) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("scanOut", TMessageType.CALL, seqid_));
      scanOut_args args = new scanOut_args();
      args.itemNumber = itemNumber;
      args.imeiNumber = imeiNumber;
      args.type = type;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_scanOut() throws WarehouseServiceException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      scanOut_result result = new scanOut_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.wex != null) {
        throw result.wex;
      }
      return;
    }

  }
  public static class Processor extends in.shop2020.generic.GenericService.Processor implements TProcessor {
    private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
    public Processor(Iface iface)
    {
      super(iface);
      iface_ = iface;
      processMap_.put("createPurchaseOrder", new createPurchaseOrder());
      processMap_.put("getPurchaseOrder", new getPurchaseOrder());
      processMap_.put("getAllPurchaseOrders", new getAllPurchaseOrders());
      processMap_.put("getSupplier", new getSupplier());
      processMap_.put("startPurchase", new startPurchase());
      processMap_.put("closePurchase", new closePurchase());
      processMap_.put("getAllPurchases", new getAllPurchases());
      processMap_.put("scanIn", new scanIn());
      processMap_.put("scanOut", new scanOut());
    }

    private Iface iface_;

    public boolean process(TProtocol iprot, TProtocol oprot) throws TException
    {
      TMessage msg = iprot.readMessageBegin();
      ProcessFunction fn = processMap_.get(msg.name);
      if (fn == null) {
        TProtocolUtil.skip(iprot, TType.STRUCT);
        iprot.readMessageEnd();
        TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
        oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
        x.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
        return true;
      }
      fn.process(msg.seqid, iprot, oprot);
      return true;
    }

    private class createPurchaseOrder implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        createPurchaseOrder_args args = new createPurchaseOrder_args();
        args.read(iprot);
        iprot.readMessageEnd();
        createPurchaseOrder_result result = new createPurchaseOrder_result();
        try {
          result.success = iface_.createPurchaseOrder(args.purchaseOrder);
          result.setSuccessIsSet(true);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing createPurchaseOrder", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing createPurchaseOrder");
          oprot.writeMessageBegin(new TMessage("createPurchaseOrder", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("createPurchaseOrder", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPurchaseOrder implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPurchaseOrder_args args = new getPurchaseOrder_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPurchaseOrder_result result = new getPurchaseOrder_result();
        try {
          result.success = iface_.getPurchaseOrder(args.id);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPurchaseOrder", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPurchaseOrder");
          oprot.writeMessageBegin(new TMessage("getPurchaseOrder", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPurchaseOrder", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getAllPurchaseOrders implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getAllPurchaseOrders_args args = new getAllPurchaseOrders_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getAllPurchaseOrders_result result = new getAllPurchaseOrders_result();
        try {
          result.success = iface_.getAllPurchaseOrders(args.status);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getAllPurchaseOrders", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getAllPurchaseOrders");
          oprot.writeMessageBegin(new TMessage("getAllPurchaseOrders", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getAllPurchaseOrders", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getSupplier implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getSupplier_args args = new getSupplier_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getSupplier_result result = new getSupplier_result();
        try {
          result.success = iface_.getSupplier(args.id);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getSupplier", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getSupplier");
          oprot.writeMessageBegin(new TMessage("getSupplier", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getSupplier", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class startPurchase implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        startPurchase_args args = new startPurchase_args();
        args.read(iprot);
        iprot.readMessageEnd();
        startPurchase_result result = new startPurchase_result();
        try {
          result.success = iface_.startPurchase(args.purchaseOrderId, args.invoiceNumber, args.freightCharges);
          result.setSuccessIsSet(true);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing startPurchase", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing startPurchase");
          oprot.writeMessageBegin(new TMessage("startPurchase", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("startPurchase", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class closePurchase implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        closePurchase_args args = new closePurchase_args();
        args.read(iprot);
        iprot.readMessageEnd();
        closePurchase_result result = new closePurchase_result();
        try {
          result.success = iface_.closePurchase(args.purchaseId);
          result.setSuccessIsSet(true);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing closePurchase", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing closePurchase");
          oprot.writeMessageBegin(new TMessage("closePurchase", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("closePurchase", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getAllPurchases implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getAllPurchases_args args = new getAllPurchases_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getAllPurchases_result result = new getAllPurchases_result();
        try {
          result.success = iface_.getAllPurchases(args.purchaseOrderId, args.open);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getAllPurchases", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getAllPurchases");
          oprot.writeMessageBegin(new TMessage("getAllPurchases", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getAllPurchases", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class scanIn implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        scanIn_args args = new scanIn_args();
        args.read(iprot);
        iprot.readMessageEnd();
        scanIn_result result = new scanIn_result();
        try {
          iface_.scanIn(args.purchaseId, args.itemNumber, args.imeiNumber, args.type);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing scanIn", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing scanIn");
          oprot.writeMessageBegin(new TMessage("scanIn", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("scanIn", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class scanOut implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        scanOut_args args = new scanOut_args();
        args.read(iprot);
        iprot.readMessageEnd();
        scanOut_result result = new scanOut_result();
        try {
          iface_.scanOut(args.itemNumber, args.imeiNumber, args.type);
        } catch (WarehouseServiceException wex) {
          result.wex = wex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing scanOut", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing scanOut");
          oprot.writeMessageBegin(new TMessage("scanOut", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("scanOut", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

  }

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

    private static final TField PURCHASE_ORDER_FIELD_DESC = new TField("purchaseOrder", TType.STRUCT, (short)1);

    private PurchaseOrder purchaseOrder;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PURCHASE_ORDER((short)1, "purchaseOrder");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PURCHASE_ORDER, new FieldMetaData("purchaseOrder", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, PurchaseOrder.class)));
    }});

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

    public createPurchaseOrder_args() {
    }

    public createPurchaseOrder_args(
      PurchaseOrder purchaseOrder)
    {
      this();
      this.purchaseOrder = purchaseOrder;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPurchaseOrder_args(createPurchaseOrder_args other) {
      if (other.isSetPurchaseOrder()) {
        this.purchaseOrder = new PurchaseOrder(other.purchaseOrder);
      }
    }

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

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

    public PurchaseOrder getPurchaseOrder() {
      return this.purchaseOrder;
    }

    public createPurchaseOrder_args setPurchaseOrder(PurchaseOrder purchaseOrder) {
      this.purchaseOrder = purchaseOrder;
      return this;
    }

    public void unsetPurchaseOrder() {
      this.purchaseOrder = null;
    }

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

    public void setPurchaseOrderIsSet(boolean value) {
      if (!value) {
        this.purchaseOrder = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PURCHASE_ORDER:
        if (value == null) {
          unsetPurchaseOrder();
        } else {
          setPurchaseOrder((PurchaseOrder)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PURCHASE_ORDER:
        return getPurchaseOrder();

      }
      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 PURCHASE_ORDER:
        return isSetPurchaseOrder();
      }
      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 createPurchaseOrder_args)
        return this.equals((createPurchaseOrder_args)that);
      return false;
    }

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

      boolean this_present_purchaseOrder = true && this.isSetPurchaseOrder();
      boolean that_present_purchaseOrder = true && that.isSetPurchaseOrder();
      if (this_present_purchaseOrder || that_present_purchaseOrder) {
        if (!(this_present_purchaseOrder && that_present_purchaseOrder))
          return false;
        if (!this.purchaseOrder.equals(that.purchaseOrder))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPurchaseOrder()).compareTo(isSetPurchaseOrder());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(purchaseOrder, typedOther.purchaseOrder);
      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 PURCHASE_ORDER:
              if (field.type == TType.STRUCT) {
                this.purchaseOrder = new PurchaseOrder();
                this.purchaseOrder.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      if (this.purchaseOrder != null) {
        oprot.writeFieldBegin(PURCHASE_ORDER_FIELD_DESC);
        this.purchaseOrder.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("purchaseOrder:");
      if (this.purchaseOrder == null) {
        sb.append("null");
      } else {
        sb.append(this.purchaseOrder);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private long success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

      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 __SUCCESS_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public createPurchaseOrder_result() {
    }

    public createPurchaseOrder_result(
      long success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      setSuccessIsSet(true);
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPurchaseOrder_result(createPurchaseOrder_result other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.success = other.success;
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public long getSuccess() {
      return this.success;
    }

    public createPurchaseOrder_result setSuccess(long success) {
      this.success = success;
      setSuccessIsSet(true);
      return this;
    }

    public void unsetSuccess() {
      __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
    }

    public void setSuccessIsSet(boolean value) {
      __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public createPurchaseOrder_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Long)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return new Long(getSuccess());

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 createPurchaseOrder_result)
        return this.equals((createPurchaseOrder_result)that);
      return false;
    }

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

      boolean this_present_success = true;
      boolean that_present_success = true;
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (this.success != that.success)
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.I64) {
                this.success = iprot.readI64();
                setSuccessIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        oprot.writeI64(this.success);
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      sb.append(this.success);
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);

    private long id;

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

      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 BitSet __isset_bit_vector = new BitSet(1);

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

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

    public getPurchaseOrder_args() {
    }

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

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPurchaseOrder_args(getPurchaseOrder_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.id = other.id;
    }

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

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

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

    public getPurchaseOrder_args 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 void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case ID:
        if (value == null) {
          unsetId();
        } else {
          setId((Long)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());

      }
      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();
      }
      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 getPurchaseOrder_args)
        return this.equals((getPurchaseOrder_args)that);
      return false;
    }

    public boolean equals(getPurchaseOrder_args 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;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(id, typedOther.id);
      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;
          }
          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.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("id:");
      sb.append(this.id);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private PurchaseOrder success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, PurchaseOrder.class)));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getPurchaseOrder_result() {
    }

    public getPurchaseOrder_result(
      PurchaseOrder success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPurchaseOrder_result(getPurchaseOrder_result other) {
      if (other.isSetSuccess()) {
        this.success = new PurchaseOrder(other.success);
      }
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public PurchaseOrder getSuccess() {
      return this.success;
    }

    public getPurchaseOrder_result setSuccess(PurchaseOrder success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public getPurchaseOrder_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((PurchaseOrder)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 getPurchaseOrder_result)
        return this.equals((getPurchaseOrder_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new PurchaseOrder();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)1);

    private POStatus status;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      /**
       * 
       * @see POStatus
       */
      STATUS((short)1, "status");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, POStatus.class)));
    }});

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

    public getAllPurchaseOrders_args() {
    }

    public getAllPurchaseOrders_args(
      POStatus status)
    {
      this();
      this.status = status;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPurchaseOrders_args(getAllPurchaseOrders_args other) {
      if (other.isSetStatus()) {
        this.status = other.status;
      }
    }

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

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

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

    /**
     * 
     * @see POStatus
     */
    public getAllPurchaseOrders_args 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 void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case STATUS:
        if (value == null) {
          unsetStatus();
        } else {
          setStatus((POStatus)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case STATUS:
        return getStatus();

      }
      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 STATUS:
        return isSetStatus();
      }
      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 getAllPurchaseOrders_args)
        return this.equals((getAllPurchaseOrders_args)that);
      return false;
    }

    public boolean equals(getAllPurchaseOrders_args that) {
      if (that == null)
        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;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(status, typedOther.status);
      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 STATUS:
              if (field.type == TType.I32) {
                this.status = POStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      if (this.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeI32(this.status.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      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;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private List<PurchaseOrder> success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, PurchaseOrder.class))));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getAllPurchaseOrders_result() {
    }

    public getAllPurchaseOrders_result(
      List<PurchaseOrder> success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPurchaseOrders_result(getAllPurchaseOrders_result other) {
      if (other.isSetSuccess()) {
        List<PurchaseOrder> __this__success = new ArrayList<PurchaseOrder>();
        for (PurchaseOrder other_element : other.success) {
          __this__success.add(new PurchaseOrder(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

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

    public java.util.Iterator<PurchaseOrder> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(PurchaseOrder elem) {
      if (this.success == null) {
        this.success = new ArrayList<PurchaseOrder>();
      }
      this.success.add(elem);
    }

    public List<PurchaseOrder> getSuccess() {
      return this.success;
    }

    public getAllPurchaseOrders_result setSuccess(List<PurchaseOrder> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public getAllPurchaseOrders_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<PurchaseOrder>)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 getAllPurchaseOrders_result)
        return this.equals((getAllPurchaseOrders_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list4 = iprot.readListBegin();
                  this.success = new ArrayList<PurchaseOrder>(_list4.size);
                  for (int _i5 = 0; _i5 < _list4.size; ++_i5)
                  {
                    PurchaseOrder _elem6;
                    _elem6 = new PurchaseOrder();
                    _elem6.read(iprot);
                    this.success.add(_elem6);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (PurchaseOrder _iter7 : this.success)
          {
            _iter7.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);

    private long id;

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

      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 BitSet __isset_bit_vector = new BitSet(1);

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

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

    public getSupplier_args() {
    }

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

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getSupplier_args(getSupplier_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.id = other.id;
    }

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

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

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

    public getSupplier_args 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 void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case ID:
        if (value == null) {
          unsetId();
        } else {
          setId((Long)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());

      }
      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();
      }
      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 getSupplier_args)
        return this.equals((getSupplier_args)that);
      return false;
    }

    public boolean equals(getSupplier_args 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;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(id, typedOther.id);
      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;
          }
          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.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("id:");
      sb.append(this.id);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private Supplier success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, Supplier.class)));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getSupplier_result() {
    }

    public getSupplier_result(
      Supplier success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getSupplier_result(getSupplier_result other) {
      if (other.isSetSuccess()) {
        this.success = new Supplier(other.success);
      }
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public Supplier getSuccess() {
      return this.success;
    }

    public getSupplier_result setSuccess(Supplier success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public getSupplier_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Supplier)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 getSupplier_result)
        return this.equals((getSupplier_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new Supplier();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PURCHASE_ORDER_ID_FIELD_DESC = new TField("purchaseOrderId", TType.I64, (short)1);
    private static final TField INVOICE_NUMBER_FIELD_DESC = new TField("invoiceNumber", TType.STRING, (short)2);
    private static final TField FREIGHT_CHARGES_FIELD_DESC = new TField("freightCharges", TType.DOUBLE, (short)3);

    private long purchaseOrderId;
    private String invoiceNumber;
    private double freightCharges;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PURCHASE_ORDER_ID((short)1, "purchaseOrderId"),
      INVOICE_NUMBER((short)2, "invoiceNumber"),
      FREIGHT_CHARGES((short)3, "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 __PURCHASEORDERID_ISSET_ID = 0;
    private static final int __FREIGHTCHARGES_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PURCHASE_ORDER_ID, new FieldMetaData("purchaseOrderId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.INVOICE_NUMBER, new FieldMetaData("invoiceNumber", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.FREIGHT_CHARGES, new FieldMetaData("freightCharges", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.DOUBLE)));
    }});

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

    public startPurchase_args() {
    }

    public startPurchase_args(
      long purchaseOrderId,
      String invoiceNumber,
      double freightCharges)
    {
      this();
      this.purchaseOrderId = purchaseOrderId;
      setPurchaseOrderIdIsSet(true);
      this.invoiceNumber = invoiceNumber;
      this.freightCharges = freightCharges;
      setFreightChargesIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public startPurchase_args(startPurchase_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.purchaseOrderId = other.purchaseOrderId;
      if (other.isSetInvoiceNumber()) {
        this.invoiceNumber = other.invoiceNumber;
      }
      this.freightCharges = other.freightCharges;
    }

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

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

    public long getPurchaseOrderId() {
      return this.purchaseOrderId;
    }

    public startPurchase_args setPurchaseOrderId(long purchaseOrderId) {
      this.purchaseOrderId = purchaseOrderId;
      setPurchaseOrderIdIsSet(true);
      return this;
    }

    public void unsetPurchaseOrderId() {
      __isset_bit_vector.clear(__PURCHASEORDERID_ISSET_ID);
    }

    /** Returns true if field purchaseOrderId is set (has been asigned a value) and false otherwise */
    public boolean isSetPurchaseOrderId() {
      return __isset_bit_vector.get(__PURCHASEORDERID_ISSET_ID);
    }

    public void setPurchaseOrderIdIsSet(boolean value) {
      __isset_bit_vector.set(__PURCHASEORDERID_ISSET_ID, value);
    }

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

    public startPurchase_args 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 double getFreightCharges() {
      return this.freightCharges;
    }

    public startPurchase_args 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 PURCHASE_ORDER_ID:
        if (value == null) {
          unsetPurchaseOrderId();
        } else {
          setPurchaseOrderId((Long)value);
        }
        break;

      case INVOICE_NUMBER:
        if (value == null) {
          unsetInvoiceNumber();
        } else {
          setInvoiceNumber((String)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 PURCHASE_ORDER_ID:
        return new Long(getPurchaseOrderId());

      case INVOICE_NUMBER:
        return getInvoiceNumber();

      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 PURCHASE_ORDER_ID:
        return isSetPurchaseOrderId();
      case INVOICE_NUMBER:
        return isSetInvoiceNumber();
      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 startPurchase_args)
        return this.equals((startPurchase_args)that);
      return false;
    }

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

      boolean this_present_purchaseOrderId = true;
      boolean that_present_purchaseOrderId = true;
      if (this_present_purchaseOrderId || that_present_purchaseOrderId) {
        if (!(this_present_purchaseOrderId && that_present_purchaseOrderId))
          return false;
        if (this.purchaseOrderId != that.purchaseOrderId)
          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_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(startPurchase_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

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

      lastComparison = Boolean.valueOf(isSetPurchaseOrderId()).compareTo(isSetPurchaseOrderId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(purchaseOrderId, typedOther.purchaseOrderId);
      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(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 PURCHASE_ORDER_ID:
              if (field.type == TType.I64) {
                this.purchaseOrderId = iprot.readI64();
                setPurchaseOrderIdIsSet(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 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(PURCHASE_ORDER_ID_FIELD_DESC);
      oprot.writeI64(this.purchaseOrderId);
      oprot.writeFieldEnd();
      if (this.invoiceNumber != null) {
        oprot.writeFieldBegin(INVOICE_NUMBER_FIELD_DESC);
        oprot.writeString(this.invoiceNumber);
        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("startPurchase_args(");
      boolean first = true;

      sb.append("purchaseOrderId:");
      sb.append(this.purchaseOrderId);
      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("freightCharges:");
      sb.append(this.freightCharges);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private long success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

      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 __SUCCESS_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public startPurchase_result() {
    }

    public startPurchase_result(
      long success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      setSuccessIsSet(true);
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public startPurchase_result(startPurchase_result other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.success = other.success;
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public long getSuccess() {
      return this.success;
    }

    public startPurchase_result setSuccess(long success) {
      this.success = success;
      setSuccessIsSet(true);
      return this;
    }

    public void unsetSuccess() {
      __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
    }

    public void setSuccessIsSet(boolean value) {
      __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public startPurchase_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Long)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return new Long(getSuccess());

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 startPurchase_result)
        return this.equals((startPurchase_result)that);
      return false;
    }

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

      boolean this_present_success = true;
      boolean that_present_success = true;
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (this.success != that.success)
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.I64) {
                this.success = iprot.readI64();
                setSuccessIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        oprot.writeI64(this.success);
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      sb.append(this.success);
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PURCHASE_ID_FIELD_DESC = new TField("purchaseId", TType.I64, (short)1);

    private long purchaseId;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PURCHASE_ID((short)1, "purchaseId");

      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 __PURCHASEID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PURCHASE_ID, new FieldMetaData("purchaseId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public closePurchase_args() {
    }

    public closePurchase_args(
      long purchaseId)
    {
      this();
      this.purchaseId = purchaseId;
      setPurchaseIdIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public closePurchase_args(closePurchase_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.purchaseId = other.purchaseId;
    }

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

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

    public long getPurchaseId() {
      return this.purchaseId;
    }

    public closePurchase_args setPurchaseId(long purchaseId) {
      this.purchaseId = purchaseId;
      setPurchaseIdIsSet(true);
      return this;
    }

    public void unsetPurchaseId() {
      __isset_bit_vector.clear(__PURCHASEID_ISSET_ID);
    }

    /** Returns true if field purchaseId is set (has been asigned a value) and false otherwise */
    public boolean isSetPurchaseId() {
      return __isset_bit_vector.get(__PURCHASEID_ISSET_ID);
    }

    public void setPurchaseIdIsSet(boolean value) {
      __isset_bit_vector.set(__PURCHASEID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PURCHASE_ID:
        if (value == null) {
          unsetPurchaseId();
        } else {
          setPurchaseId((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PURCHASE_ID:
        return new Long(getPurchaseId());

      }
      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 PURCHASE_ID:
        return isSetPurchaseId();
      }
      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 closePurchase_args)
        return this.equals((closePurchase_args)that);
      return false;
    }

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

      boolean this_present_purchaseId = true;
      boolean that_present_purchaseId = true;
      if (this_present_purchaseId || that_present_purchaseId) {
        if (!(this_present_purchaseId && that_present_purchaseId))
          return false;
        if (this.purchaseId != that.purchaseId)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPurchaseId()).compareTo(isSetPurchaseId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(purchaseId, typedOther.purchaseId);
      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 PURCHASE_ID:
              if (field.type == TType.I64) {
                this.purchaseId = iprot.readI64();
                setPurchaseIdIsSet(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(PURCHASE_ID_FIELD_DESC);
      oprot.writeI64(this.purchaseId);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("purchaseId:");
      sb.append(this.purchaseId);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private long success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

      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 __SUCCESS_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public closePurchase_result() {
    }

    public closePurchase_result(
      long success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      setSuccessIsSet(true);
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public closePurchase_result(closePurchase_result other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.success = other.success;
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public long getSuccess() {
      return this.success;
    }

    public closePurchase_result setSuccess(long success) {
      this.success = success;
      setSuccessIsSet(true);
      return this;
    }

    public void unsetSuccess() {
      __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return __isset_bit_vector.get(__SUCCESS_ISSET_ID);
    }

    public void setSuccessIsSet(boolean value) {
      __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public closePurchase_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Long)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return new Long(getSuccess());

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 closePurchase_result)
        return this.equals((closePurchase_result)that);
      return false;
    }

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

      boolean this_present_success = true;
      boolean that_present_success = true;
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (this.success != that.success)
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.I64) {
                this.success = iprot.readI64();
                setSuccessIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        oprot.writeI64(this.success);
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      sb.append(this.success);
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PURCHASE_ORDER_ID_FIELD_DESC = new TField("purchaseOrderId", TType.I64, (short)1);
    private static final TField OPEN_FIELD_DESC = new TField("open", TType.BOOL, (short)2);

    private long purchaseOrderId;
    private boolean open;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PURCHASE_ORDER_ID((short)1, "purchaseOrderId"),
      OPEN((short)2, "open");

      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 __PURCHASEORDERID_ISSET_ID = 0;
    private static final int __OPEN_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PURCHASE_ORDER_ID, new FieldMetaData("purchaseOrderId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.OPEN, new FieldMetaData("open", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.BOOL)));
    }});

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

    public getAllPurchases_args() {
    }

    public getAllPurchases_args(
      long purchaseOrderId,
      boolean open)
    {
      this();
      this.purchaseOrderId = purchaseOrderId;
      setPurchaseOrderIdIsSet(true);
      this.open = open;
      setOpenIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPurchases_args(getAllPurchases_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.purchaseOrderId = other.purchaseOrderId;
      this.open = other.open;
    }

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

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

    public long getPurchaseOrderId() {
      return this.purchaseOrderId;
    }

    public getAllPurchases_args setPurchaseOrderId(long purchaseOrderId) {
      this.purchaseOrderId = purchaseOrderId;
      setPurchaseOrderIdIsSet(true);
      return this;
    }

    public void unsetPurchaseOrderId() {
      __isset_bit_vector.clear(__PURCHASEORDERID_ISSET_ID);
    }

    /** Returns true if field purchaseOrderId is set (has been asigned a value) and false otherwise */
    public boolean isSetPurchaseOrderId() {
      return __isset_bit_vector.get(__PURCHASEORDERID_ISSET_ID);
    }

    public void setPurchaseOrderIdIsSet(boolean value) {
      __isset_bit_vector.set(__PURCHASEORDERID_ISSET_ID, value);
    }

    public boolean isOpen() {
      return this.open;
    }

    public getAllPurchases_args setOpen(boolean open) {
      this.open = open;
      setOpenIsSet(true);
      return this;
    }

    public void unsetOpen() {
      __isset_bit_vector.clear(__OPEN_ISSET_ID);
    }

    /** Returns true if field open is set (has been asigned a value) and false otherwise */
    public boolean isSetOpen() {
      return __isset_bit_vector.get(__OPEN_ISSET_ID);
    }

    public void setOpenIsSet(boolean value) {
      __isset_bit_vector.set(__OPEN_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PURCHASE_ORDER_ID:
        if (value == null) {
          unsetPurchaseOrderId();
        } else {
          setPurchaseOrderId((Long)value);
        }
        break;

      case OPEN:
        if (value == null) {
          unsetOpen();
        } else {
          setOpen((Boolean)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PURCHASE_ORDER_ID:
        return new Long(getPurchaseOrderId());

      case OPEN:
        return new Boolean(isOpen());

      }
      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 PURCHASE_ORDER_ID:
        return isSetPurchaseOrderId();
      case OPEN:
        return isSetOpen();
      }
      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 getAllPurchases_args)
        return this.equals((getAllPurchases_args)that);
      return false;
    }

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

      boolean this_present_purchaseOrderId = true;
      boolean that_present_purchaseOrderId = true;
      if (this_present_purchaseOrderId || that_present_purchaseOrderId) {
        if (!(this_present_purchaseOrderId && that_present_purchaseOrderId))
          return false;
        if (this.purchaseOrderId != that.purchaseOrderId)
          return false;
      }

      boolean this_present_open = true;
      boolean that_present_open = true;
      if (this_present_open || that_present_open) {
        if (!(this_present_open && that_present_open))
          return false;
        if (this.open != that.open)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPurchaseOrderId()).compareTo(isSetPurchaseOrderId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(purchaseOrderId, typedOther.purchaseOrderId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetOpen()).compareTo(isSetOpen());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(open, typedOther.open);
      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 PURCHASE_ORDER_ID:
              if (field.type == TType.I64) {
                this.purchaseOrderId = iprot.readI64();
                setPurchaseOrderIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case OPEN:
              if (field.type == TType.BOOL) {
                this.open = iprot.readBool();
                setOpenIsSet(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(PURCHASE_ORDER_ID_FIELD_DESC);
      oprot.writeI64(this.purchaseOrderId);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(OPEN_FIELD_DESC);
      oprot.writeBool(this.open);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("purchaseOrderId:");
      sb.append(this.purchaseOrderId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("open:");
      sb.append(this.open);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private List<Purchase> success;
    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Purchase.class))));
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getAllPurchases_result() {
    }

    public getAllPurchases_result(
      List<Purchase> success,
      WarehouseServiceException wex)
    {
      this();
      this.success = success;
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPurchases_result(getAllPurchases_result other) {
      if (other.isSetSuccess()) {
        List<Purchase> __this__success = new ArrayList<Purchase>();
        for (Purchase other_element : other.success) {
          __this__success.add(new Purchase(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

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

    public java.util.Iterator<Purchase> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(Purchase elem) {
      if (this.success == null) {
        this.success = new ArrayList<Purchase>();
      }
      this.success.add(elem);
    }

    public List<Purchase> getSuccess() {
      return this.success;
    }

    public getAllPurchases_result setSuccess(List<Purchase> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public getAllPurchases_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<Purchase>)value);
        }
        break;

      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case WEX:
        return getWex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case WEX:
        return isSetWex();
      }
      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 getAllPurchases_result)
        return this.equals((getAllPurchases_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list8 = iprot.readListBegin();
                  this.success = new ArrayList<Purchase>(_list8.size);
                  for (int _i9 = 0; _i9 < _list8.size; ++_i9)
                  {
                    Purchase _elem10;
                    _elem10 = new Purchase();
                    _elem10.read(iprot);
                    this.success.add(_elem10);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (Purchase _iter11 : this.success)
          {
            _iter11.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PURCHASE_ID_FIELD_DESC = new TField("purchaseId", TType.I64, (short)1);
    private static final TField ITEM_NUMBER_FIELD_DESC = new TField("itemNumber", TType.STRING, (short)2);
    private static final TField IMEI_NUMBER_FIELD_DESC = new TField("imeiNumber", TType.STRING, (short)3);
    private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)4);

    private long purchaseId;
    private String itemNumber;
    private String imeiNumber;
    private ScanType type;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PURCHASE_ID((short)1, "purchaseId"),
      ITEM_NUMBER((short)2, "itemNumber"),
      IMEI_NUMBER((short)3, "imeiNumber"),
      /**
       * 
       * @see ScanType
       */
      TYPE((short)4, "type");

      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 __PURCHASEID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PURCHASE_ID, new FieldMetaData("purchaseId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.ITEM_NUMBER, new FieldMetaData("itemNumber", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.IMEI_NUMBER, new FieldMetaData("imeiNumber", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, ScanType.class)));
    }});

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

    public scanIn_args() {
    }

    public scanIn_args(
      long purchaseId,
      String itemNumber,
      String imeiNumber,
      ScanType type)
    {
      this();
      this.purchaseId = purchaseId;
      setPurchaseIdIsSet(true);
      this.itemNumber = itemNumber;
      this.imeiNumber = imeiNumber;
      this.type = type;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public scanIn_args(scanIn_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.purchaseId = other.purchaseId;
      if (other.isSetItemNumber()) {
        this.itemNumber = other.itemNumber;
      }
      if (other.isSetImeiNumber()) {
        this.imeiNumber = other.imeiNumber;
      }
      if (other.isSetType()) {
        this.type = other.type;
      }
    }

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

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

    public long getPurchaseId() {
      return this.purchaseId;
    }

    public scanIn_args setPurchaseId(long purchaseId) {
      this.purchaseId = purchaseId;
      setPurchaseIdIsSet(true);
      return this;
    }

    public void unsetPurchaseId() {
      __isset_bit_vector.clear(__PURCHASEID_ISSET_ID);
    }

    /** Returns true if field purchaseId is set (has been asigned a value) and false otherwise */
    public boolean isSetPurchaseId() {
      return __isset_bit_vector.get(__PURCHASEID_ISSET_ID);
    }

    public void setPurchaseIdIsSet(boolean value) {
      __isset_bit_vector.set(__PURCHASEID_ISSET_ID, value);
    }

    public String getItemNumber() {
      return this.itemNumber;
    }

    public scanIn_args setItemNumber(String itemNumber) {
      this.itemNumber = itemNumber;
      return this;
    }

    public void unsetItemNumber() {
      this.itemNumber = null;
    }

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

    public void setItemNumberIsSet(boolean value) {
      if (!value) {
        this.itemNumber = null;
      }
    }

    public String getImeiNumber() {
      return this.imeiNumber;
    }

    public scanIn_args setImeiNumber(String imeiNumber) {
      this.imeiNumber = imeiNumber;
      return this;
    }

    public void unsetImeiNumber() {
      this.imeiNumber = null;
    }

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

    public void setImeiNumberIsSet(boolean value) {
      if (!value) {
        this.imeiNumber = null;
      }
    }

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

    /**
     * 
     * @see ScanType
     */
    public scanIn_args setType(ScanType type) {
      this.type = type;
      return this;
    }

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

    /** Returns true if field type is set (has been asigned 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 PURCHASE_ID:
        if (value == null) {
          unsetPurchaseId();
        } else {
          setPurchaseId((Long)value);
        }
        break;

      case ITEM_NUMBER:
        if (value == null) {
          unsetItemNumber();
        } else {
          setItemNumber((String)value);
        }
        break;

      case IMEI_NUMBER:
        if (value == null) {
          unsetImeiNumber();
        } else {
          setImeiNumber((String)value);
        }
        break;

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

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PURCHASE_ID:
        return new Long(getPurchaseId());

      case ITEM_NUMBER:
        return getItemNumber();

      case IMEI_NUMBER:
        return getImeiNumber();

      case TYPE:
        return getType();

      }
      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 PURCHASE_ID:
        return isSetPurchaseId();
      case ITEM_NUMBER:
        return isSetItemNumber();
      case IMEI_NUMBER:
        return isSetImeiNumber();
      case TYPE:
        return isSetType();
      }
      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 scanIn_args)
        return this.equals((scanIn_args)that);
      return false;
    }

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

      boolean this_present_purchaseId = true;
      boolean that_present_purchaseId = true;
      if (this_present_purchaseId || that_present_purchaseId) {
        if (!(this_present_purchaseId && that_present_purchaseId))
          return false;
        if (this.purchaseId != that.purchaseId)
          return false;
      }

      boolean this_present_itemNumber = true && this.isSetItemNumber();
      boolean that_present_itemNumber = true && that.isSetItemNumber();
      if (this_present_itemNumber || that_present_itemNumber) {
        if (!(this_present_itemNumber && that_present_itemNumber))
          return false;
        if (!this.itemNumber.equals(that.itemNumber))
          return false;
      }

      boolean this_present_imeiNumber = true && this.isSetImeiNumber();
      boolean that_present_imeiNumber = true && that.isSetImeiNumber();
      if (this_present_imeiNumber || that_present_imeiNumber) {
        if (!(this_present_imeiNumber && that_present_imeiNumber))
          return false;
        if (!this.imeiNumber.equals(that.imeiNumber))
          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(scanIn_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

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

      lastComparison = Boolean.valueOf(isSetPurchaseId()).compareTo(isSetPurchaseId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(purchaseId, typedOther.purchaseId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetItemNumber()).compareTo(isSetItemNumber());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(itemNumber, typedOther.itemNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetImeiNumber()).compareTo(isSetImeiNumber());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(imeiNumber, typedOther.imeiNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetType()).compareTo(isSetType());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(type, typedOther.type);
      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 PURCHASE_ID:
              if (field.type == TType.I64) {
                this.purchaseId = iprot.readI64();
                setPurchaseIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case ITEM_NUMBER:
              if (field.type == TType.STRING) {
                this.itemNumber = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case IMEI_NUMBER:
              if (field.type == TType.STRING) {
                this.imeiNumber = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TYPE:
              if (field.type == TType.I32) {
                this.type = ScanType.findByValue(iprot.readI32());
              } 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(PURCHASE_ID_FIELD_DESC);
      oprot.writeI64(this.purchaseId);
      oprot.writeFieldEnd();
      if (this.itemNumber != null) {
        oprot.writeFieldBegin(ITEM_NUMBER_FIELD_DESC);
        oprot.writeString(this.itemNumber);
        oprot.writeFieldEnd();
      }
      if (this.imeiNumber != null) {
        oprot.writeFieldBegin(IMEI_NUMBER_FIELD_DESC);
        oprot.writeString(this.imeiNumber);
        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("scanIn_args(");
      boolean first = true;

      sb.append("purchaseId:");
      sb.append(this.purchaseId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("itemNumber:");
      if (this.itemNumber == null) {
        sb.append("null");
      } else {
        sb.append(this.itemNumber);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("imeiNumber:");
      if (this.imeiNumber == null) {
        sb.append("null");
      } else {
        sb.append(this.imeiNumber);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("type:");
      if (this.type == null) {
        sb.append("null");
      } else {
        String type_name = type.name();
        if (type_name != null) {
          sb.append(type_name);
          sb.append(" (");
        }
        sb.append(this.type);
        if (type_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public scanIn_result() {
    }

    public scanIn_result(
      WarehouseServiceException wex)
    {
      this();
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public scanIn_result(scanIn_result other) {
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public scanIn_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case WEX:
        return getWex();

      }
      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 WEX:
        return isSetWex();
      }
      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 scanIn_result)
        return this.equals((scanIn_result)that);
      return false;
    }

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

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField ITEM_NUMBER_FIELD_DESC = new TField("itemNumber", TType.I64, (short)1);
    private static final TField IMEI_NUMBER_FIELD_DESC = new TField("imeiNumber", TType.I64, (short)2);
    private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)3);

    private long itemNumber;
    private long imeiNumber;
    private ScanType type;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      ITEM_NUMBER((short)1, "itemNumber"),
      IMEI_NUMBER((short)2, "imeiNumber"),
      /**
       * 
       * @see ScanType
       */
      TYPE((short)3, "type");

      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 __ITEMNUMBER_ISSET_ID = 0;
    private static final int __IMEINUMBER_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.ITEM_NUMBER, new FieldMetaData("itemNumber", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.IMEI_NUMBER, new FieldMetaData("imeiNumber", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, ScanType.class)));
    }});

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

    public scanOut_args() {
    }

    public scanOut_args(
      long itemNumber,
      long imeiNumber,
      ScanType type)
    {
      this();
      this.itemNumber = itemNumber;
      setItemNumberIsSet(true);
      this.imeiNumber = imeiNumber;
      setImeiNumberIsSet(true);
      this.type = type;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public scanOut_args(scanOut_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.itemNumber = other.itemNumber;
      this.imeiNumber = other.imeiNumber;
      if (other.isSetType()) {
        this.type = other.type;
      }
    }

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

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

    public long getItemNumber() {
      return this.itemNumber;
    }

    public scanOut_args setItemNumber(long itemNumber) {
      this.itemNumber = itemNumber;
      setItemNumberIsSet(true);
      return this;
    }

    public void unsetItemNumber() {
      __isset_bit_vector.clear(__ITEMNUMBER_ISSET_ID);
    }

    /** Returns true if field itemNumber is set (has been asigned a value) and false otherwise */
    public boolean isSetItemNumber() {
      return __isset_bit_vector.get(__ITEMNUMBER_ISSET_ID);
    }

    public void setItemNumberIsSet(boolean value) {
      __isset_bit_vector.set(__ITEMNUMBER_ISSET_ID, value);
    }

    public long getImeiNumber() {
      return this.imeiNumber;
    }

    public scanOut_args setImeiNumber(long imeiNumber) {
      this.imeiNumber = imeiNumber;
      setImeiNumberIsSet(true);
      return this;
    }

    public void unsetImeiNumber() {
      __isset_bit_vector.clear(__IMEINUMBER_ISSET_ID);
    }

    /** Returns true if field imeiNumber is set (has been asigned a value) and false otherwise */
    public boolean isSetImeiNumber() {
      return __isset_bit_vector.get(__IMEINUMBER_ISSET_ID);
    }

    public void setImeiNumberIsSet(boolean value) {
      __isset_bit_vector.set(__IMEINUMBER_ISSET_ID, value);
    }

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

    /**
     * 
     * @see ScanType
     */
    public scanOut_args setType(ScanType type) {
      this.type = type;
      return this;
    }

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

    /** Returns true if field type is set (has been asigned 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 ITEM_NUMBER:
        if (value == null) {
          unsetItemNumber();
        } else {
          setItemNumber((Long)value);
        }
        break;

      case IMEI_NUMBER:
        if (value == null) {
          unsetImeiNumber();
        } else {
          setImeiNumber((Long)value);
        }
        break;

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

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case ITEM_NUMBER:
        return new Long(getItemNumber());

      case IMEI_NUMBER:
        return new Long(getImeiNumber());

      case TYPE:
        return getType();

      }
      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 ITEM_NUMBER:
        return isSetItemNumber();
      case IMEI_NUMBER:
        return isSetImeiNumber();
      case TYPE:
        return isSetType();
      }
      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 scanOut_args)
        return this.equals((scanOut_args)that);
      return false;
    }

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

      boolean this_present_itemNumber = true;
      boolean that_present_itemNumber = true;
      if (this_present_itemNumber || that_present_itemNumber) {
        if (!(this_present_itemNumber && that_present_itemNumber))
          return false;
        if (this.itemNumber != that.itemNumber)
          return false;
      }

      boolean this_present_imeiNumber = true;
      boolean that_present_imeiNumber = true;
      if (this_present_imeiNumber || that_present_imeiNumber) {
        if (!(this_present_imeiNumber && that_present_imeiNumber))
          return false;
        if (this.imeiNumber != that.imeiNumber)
          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(scanOut_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

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

      lastComparison = Boolean.valueOf(isSetItemNumber()).compareTo(isSetItemNumber());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(itemNumber, typedOther.itemNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetImeiNumber()).compareTo(isSetImeiNumber());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(imeiNumber, typedOther.imeiNumber);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetType()).compareTo(isSetType());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(type, typedOther.type);
      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 ITEM_NUMBER:
              if (field.type == TType.I64) {
                this.itemNumber = iprot.readI64();
                setItemNumberIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case IMEI_NUMBER:
              if (field.type == TType.I64) {
                this.imeiNumber = iprot.readI64();
                setImeiNumberIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TYPE:
              if (field.type == TType.I32) {
                this.type = ScanType.findByValue(iprot.readI32());
              } 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(ITEM_NUMBER_FIELD_DESC);
      oprot.writeI64(this.itemNumber);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(IMEI_NUMBER_FIELD_DESC);
      oprot.writeI64(this.imeiNumber);
      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("scanOut_args(");
      boolean first = true;

      sb.append("itemNumber:");
      sb.append(this.itemNumber);
      first = false;
      if (!first) sb.append(", ");
      sb.append("imeiNumber:");
      sb.append(this.imeiNumber);
      first = false;
      if (!first) sb.append(", ");
      sb.append("type:");
      if (this.type == null) {
        sb.append("null");
      } else {
        String type_name = type.name();
        if (type_name != null) {
          sb.append(type_name);
          sb.append(" (");
        }
        sb.append(this.type);
        if (type_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField WEX_FIELD_DESC = new TField("wex", TType.STRUCT, (short)1);

    private WarehouseServiceException wex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      WEX((short)1, "wex");

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

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

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

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.WEX, new FieldMetaData("wex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public scanOut_result() {
    }

    public scanOut_result(
      WarehouseServiceException wex)
    {
      this();
      this.wex = wex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public scanOut_result(scanOut_result other) {
      if (other.isSetWex()) {
        this.wex = new WarehouseServiceException(other.wex);
      }
    }

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

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

    public WarehouseServiceException getWex() {
      return this.wex;
    }

    public scanOut_result setWex(WarehouseServiceException wex) {
      this.wex = wex;
      return this;
    }

    public void unsetWex() {
      this.wex = null;
    }

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

    public void setWexIsSet(boolean value) {
      if (!value) {
        this.wex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case WEX:
        if (value == null) {
          unsetWex();
        } else {
          setWex((WarehouseServiceException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case WEX:
        return getWex();

      }
      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 WEX:
        return isSetWex();
      }
      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 scanOut_result)
        return this.equals((scanOut_result)that);
      return false;
    }

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

      boolean this_present_wex = true && this.isSetWex();
      boolean that_present_wex = true && that.isSetWex();
      if (this_present_wex || that_present_wex) {
        if (!(this_present_wex && that_present_wex))
          return false;
        if (!this.wex.equals(that.wex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetWex()).compareTo(isSetWex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(wex, typedOther.wex);
      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 WEX:
              if (field.type == TType.STRUCT) {
                this.wex = new WarehouseServiceException();
                this.wex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetWex()) {
        oprot.writeFieldBegin(WEX_FIELD_DESC);
        this.wex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("wex:");
      if (this.wex == null) {
        sb.append("null");
      } else {
        sb.append(this.wex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

}