Subversion Repositories SmartDukaan

Rev

Rev 132 | Blame | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.model.v1.order;

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

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField ADDRESS_FIELD_DESC = new TField("address", TType.STRING, (short)2);
  private static final TField TRACKING_ID_FIELD_DESC = new TField("trackingId", TType.STRING, (short)3);
  private static final TField LINE_ITEMS_FIELD_DESC = new TField("lineItems", TType.LIST, (short)4);
  private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)5);
  private static final TField SHIPMENT_TIMESTAMP_FIELD_DESC = new TField("shipmentTimestamp", TType.I64, (short)6);
  private static final TField DELIVERY_TIMESTAMP_FIELD_DESC = new TField("deliveryTimestamp", TType.I64, (short)7);
  private static final TField VALUE_FIELD_DESC = new TField("value", TType.DOUBLE, (short)8);
  private static final TField INSURANCE_FIELD_DESC = new TField("insurance", TType.DOUBLE, (short)9);
  private static final TField WEIGHT_FIELD_DESC = new TField("weight", TType.DOUBLE, (short)10);
  private static final TField AIRWAY_BILL_NO_FIELD_DESC = new TField("airwayBillNo", TType.STRING, (short)11);
  private static final TField PROVIDER_FIELD_DESC = new TField("provider", TType.STRING, (short)12);

  private long id;
  private String address;
  private String trackingId;
  private List<LineItem> lineItems;
  private ShipmentStatus status;
  private long shipmentTimestamp;
  private long deliveryTimestamp;
  private double value;
  private double insurance;
  private double weight;
  private String airwayBillNo;
  private String provider;

  /** 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"),
    ADDRESS((short)2, "address"),
    TRACKING_ID((short)3, "trackingId"),
    LINE_ITEMS((short)4, "lineItems"),
    /**
     * 
     * @see ShipmentStatus
     */
    STATUS((short)5, "status"),
    SHIPMENT_TIMESTAMP((short)6, "shipmentTimestamp"),
    DELIVERY_TIMESTAMP((short)7, "deliveryTimestamp"),
    VALUE((short)8, "value"),
    INSURANCE((short)9, "insurance"),
    WEIGHT((short)10, "weight"),
    AIRWAY_BILL_NO((short)11, "airwayBillNo"),
    PROVIDER((short)12, "provider");

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

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

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

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

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

    private final short _thriftId;
    private final String _fieldName;

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

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __ID_ISSET_ID = 0;
  private static final int __SHIPMENTTIMESTAMP_ISSET_ID = 1;
  private static final int __DELIVERYTIMESTAMP_ISSET_ID = 2;
  private static final int __VALUE_ISSET_ID = 3;
  private static final int __INSURANCE_ISSET_ID = 4;
  private static final int __WEIGHT_ISSET_ID = 5;
  private BitSet __isset_bit_vector = new BitSet(6);

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.ADDRESS, new FieldMetaData("address", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.TRACKING_ID, new FieldMetaData("trackingId", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.LINE_ITEMS, new FieldMetaData("lineItems", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, LineItem.class))));
    put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, ShipmentStatus.class)));
    put(_Fields.SHIPMENT_TIMESTAMP, new FieldMetaData("shipmentTimestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.DELIVERY_TIMESTAMP, new FieldMetaData("deliveryTimestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.INSURANCE, new FieldMetaData("insurance", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.WEIGHT, new FieldMetaData("weight", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.AIRWAY_BILL_NO, new FieldMetaData("airwayBillNo", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.PROVIDER, new FieldMetaData("provider", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
  }});

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

  public Shipment() {
  }

  public Shipment(
    long id,
    String address,
    String trackingId,
    List<LineItem> lineItems,
    ShipmentStatus status,
    long shipmentTimestamp,
    long deliveryTimestamp,
    double value,
    double insurance,
    double weight,
    String airwayBillNo,
    String provider)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.address = address;
    this.trackingId = trackingId;
    this.lineItems = lineItems;
    this.status = status;
    this.shipmentTimestamp = shipmentTimestamp;
    setShipmentTimestampIsSet(true);
    this.deliveryTimestamp = deliveryTimestamp;
    setDeliveryTimestampIsSet(true);
    this.value = value;
    setValueIsSet(true);
    this.insurance = insurance;
    setInsuranceIsSet(true);
    this.weight = weight;
    setWeightIsSet(true);
    this.airwayBillNo = airwayBillNo;
    this.provider = provider;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Shipment(Shipment other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetAddress()) {
      this.address = other.address;
    }
    if (other.isSetTrackingId()) {
      this.trackingId = other.trackingId;
    }
    if (other.isSetLineItems()) {
      List<LineItem> __this__lineItems = new ArrayList<LineItem>();
      for (LineItem other_element : other.lineItems) {
        __this__lineItems.add(new LineItem(other_element));
      }
      this.lineItems = __this__lineItems;
    }
    if (other.isSetStatus()) {
      this.status = other.status;
    }
    this.shipmentTimestamp = other.shipmentTimestamp;
    this.deliveryTimestamp = other.deliveryTimestamp;
    this.value = other.value;
    this.insurance = other.insurance;
    this.weight = other.weight;
    if (other.isSetAirwayBillNo()) {
      this.airwayBillNo = other.airwayBillNo;
    }
    if (other.isSetProvider()) {
      this.provider = other.provider;
    }
  }

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

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

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

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

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

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

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

  public String getAddress() {
    return this.address;
  }

  public Shipment setAddress(String address) {
    this.address = address;
    return this;
  }

  public void unsetAddress() {
    this.address = null;
  }

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

  public void setAddressIsSet(boolean value) {
    if (!value) {
      this.address = null;
    }
  }

  public String getTrackingId() {
    return this.trackingId;
  }

  public Shipment setTrackingId(String trackingId) {
    this.trackingId = trackingId;
    return this;
  }

  public void unsetTrackingId() {
    this.trackingId = null;
  }

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

  public void setTrackingIdIsSet(boolean value) {
    if (!value) {
      this.trackingId = null;
    }
  }

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

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

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

  public List<LineItem> getLineItems() {
    return this.lineItems;
  }

  public Shipment setLineItems(List<LineItem> lineItems) {
    this.lineItems = lineItems;
    return this;
  }

  public void unsetLineItems() {
    this.lineItems = null;
  }

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

  public void setLineItemsIsSet(boolean value) {
    if (!value) {
      this.lineItems = null;
    }
  }

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

  /**
   * 
   * @see ShipmentStatus
   */
  public Shipment setStatus(ShipmentStatus status) {
    this.status = status;
    return this;
  }

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

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

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

  public long getShipmentTimestamp() {
    return this.shipmentTimestamp;
  }

  public Shipment setShipmentTimestamp(long shipmentTimestamp) {
    this.shipmentTimestamp = shipmentTimestamp;
    setShipmentTimestampIsSet(true);
    return this;
  }

  public void unsetShipmentTimestamp() {
    __isset_bit_vector.clear(__SHIPMENTTIMESTAMP_ISSET_ID);
  }

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

  public void setShipmentTimestampIsSet(boolean value) {
    __isset_bit_vector.set(__SHIPMENTTIMESTAMP_ISSET_ID, value);
  }

  public long getDeliveryTimestamp() {
    return this.deliveryTimestamp;
  }

  public Shipment setDeliveryTimestamp(long deliveryTimestamp) {
    this.deliveryTimestamp = deliveryTimestamp;
    setDeliveryTimestampIsSet(true);
    return this;
  }

  public void unsetDeliveryTimestamp() {
    __isset_bit_vector.clear(__DELIVERYTIMESTAMP_ISSET_ID);
  }

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

  public void setDeliveryTimestampIsSet(boolean value) {
    __isset_bit_vector.set(__DELIVERYTIMESTAMP_ISSET_ID, value);
  }

  public double getValue() {
    return this.value;
  }

  public Shipment setValue(double value) {
    this.value = value;
    setValueIsSet(true);
    return this;
  }

  public void unsetValue() {
    __isset_bit_vector.clear(__VALUE_ISSET_ID);
  }

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

  public void setValueIsSet(boolean value) {
    __isset_bit_vector.set(__VALUE_ISSET_ID, value);
  }

  public double getInsurance() {
    return this.insurance;
  }

  public Shipment setInsurance(double insurance) {
    this.insurance = insurance;
    setInsuranceIsSet(true);
    return this;
  }

  public void unsetInsurance() {
    __isset_bit_vector.clear(__INSURANCE_ISSET_ID);
  }

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

  public void setInsuranceIsSet(boolean value) {
    __isset_bit_vector.set(__INSURANCE_ISSET_ID, value);
  }

  public double getWeight() {
    return this.weight;
  }

  public Shipment setWeight(double weight) {
    this.weight = weight;
    setWeightIsSet(true);
    return this;
  }

  public void unsetWeight() {
    __isset_bit_vector.clear(__WEIGHT_ISSET_ID);
  }

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

  public void setWeightIsSet(boolean value) {
    __isset_bit_vector.set(__WEIGHT_ISSET_ID, value);
  }

  public String getAirwayBillNo() {
    return this.airwayBillNo;
  }

  public Shipment setAirwayBillNo(String airwayBillNo) {
    this.airwayBillNo = airwayBillNo;
    return this;
  }

  public void unsetAirwayBillNo() {
    this.airwayBillNo = null;
  }

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

  public void setAirwayBillNoIsSet(boolean value) {
    if (!value) {
      this.airwayBillNo = null;
    }
  }

  public String getProvider() {
    return this.provider;
  }

  public Shipment setProvider(String provider) {
    this.provider = provider;
    return this;
  }

  public void unsetProvider() {
    this.provider = null;
  }

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

  public void setProviderIsSet(boolean value) {
    if (!value) {
      this.provider = null;
    }
  }

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

    case ADDRESS:
      if (value == null) {
        unsetAddress();
      } else {
        setAddress((String)value);
      }
      break;

    case TRACKING_ID:
      if (value == null) {
        unsetTrackingId();
      } else {
        setTrackingId((String)value);
      }
      break;

    case LINE_ITEMS:
      if (value == null) {
        unsetLineItems();
      } else {
        setLineItems((List<LineItem>)value);
      }
      break;

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

    case SHIPMENT_TIMESTAMP:
      if (value == null) {
        unsetShipmentTimestamp();
      } else {
        setShipmentTimestamp((Long)value);
      }
      break;

    case DELIVERY_TIMESTAMP:
      if (value == null) {
        unsetDeliveryTimestamp();
      } else {
        setDeliveryTimestamp((Long)value);
      }
      break;

    case VALUE:
      if (value == null) {
        unsetValue();
      } else {
        setValue((Double)value);
      }
      break;

    case INSURANCE:
      if (value == null) {
        unsetInsurance();
      } else {
        setInsurance((Double)value);
      }
      break;

    case WEIGHT:
      if (value == null) {
        unsetWeight();
      } else {
        setWeight((Double)value);
      }
      break;

    case AIRWAY_BILL_NO:
      if (value == null) {
        unsetAirwayBillNo();
      } else {
        setAirwayBillNo((String)value);
      }
      break;

    case PROVIDER:
      if (value == null) {
        unsetProvider();
      } else {
        setProvider((String)value);
      }
      break;

    }
  }

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

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

    case ADDRESS:
      return getAddress();

    case TRACKING_ID:
      return getTrackingId();

    case LINE_ITEMS:
      return getLineItems();

    case STATUS:
      return getStatus();

    case SHIPMENT_TIMESTAMP:
      return new Long(getShipmentTimestamp());

    case DELIVERY_TIMESTAMP:
      return new Long(getDeliveryTimestamp());

    case VALUE:
      return new Double(getValue());

    case INSURANCE:
      return new Double(getInsurance());

    case WEIGHT:
      return new Double(getWeight());

    case AIRWAY_BILL_NO:
      return getAirwayBillNo();

    case PROVIDER:
      return getProvider();

    }
    throw new IllegalStateException();
  }

  public Object getFieldValue(int fieldId) {
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    switch (field) {
    case ID:
      return isSetId();
    case ADDRESS:
      return isSetAddress();
    case TRACKING_ID:
      return isSetTrackingId();
    case LINE_ITEMS:
      return isSetLineItems();
    case STATUS:
      return isSetStatus();
    case SHIPMENT_TIMESTAMP:
      return isSetShipmentTimestamp();
    case DELIVERY_TIMESTAMP:
      return isSetDeliveryTimestamp();
    case VALUE:
      return isSetValue();
    case INSURANCE:
      return isSetInsurance();
    case WEIGHT:
      return isSetWeight();
    case AIRWAY_BILL_NO:
      return isSetAirwayBillNo();
    case PROVIDER:
      return isSetProvider();
    }
    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 Shipment)
      return this.equals((Shipment)that);
    return false;
  }

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

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

    boolean this_present_address = true && this.isSetAddress();
    boolean that_present_address = true && that.isSetAddress();
    if (this_present_address || that_present_address) {
      if (!(this_present_address && that_present_address))
        return false;
      if (!this.address.equals(that.address))
        return false;
    }

    boolean this_present_trackingId = true && this.isSetTrackingId();
    boolean that_present_trackingId = true && that.isSetTrackingId();
    if (this_present_trackingId || that_present_trackingId) {
      if (!(this_present_trackingId && that_present_trackingId))
        return false;
      if (!this.trackingId.equals(that.trackingId))
        return false;
    }

    boolean this_present_lineItems = true && this.isSetLineItems();
    boolean that_present_lineItems = true && that.isSetLineItems();
    if (this_present_lineItems || that_present_lineItems) {
      if (!(this_present_lineItems && that_present_lineItems))
        return false;
      if (!this.lineItems.equals(that.lineItems))
        return false;
    }

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

    boolean this_present_shipmentTimestamp = true;
    boolean that_present_shipmentTimestamp = true;
    if (this_present_shipmentTimestamp || that_present_shipmentTimestamp) {
      if (!(this_present_shipmentTimestamp && that_present_shipmentTimestamp))
        return false;
      if (this.shipmentTimestamp != that.shipmentTimestamp)
        return false;
    }

    boolean this_present_deliveryTimestamp = true;
    boolean that_present_deliveryTimestamp = true;
    if (this_present_deliveryTimestamp || that_present_deliveryTimestamp) {
      if (!(this_present_deliveryTimestamp && that_present_deliveryTimestamp))
        return false;
      if (this.deliveryTimestamp != that.deliveryTimestamp)
        return false;
    }

    boolean this_present_value = true;
    boolean that_present_value = true;
    if (this_present_value || that_present_value) {
      if (!(this_present_value && that_present_value))
        return false;
      if (this.value != that.value)
        return false;
    }

    boolean this_present_insurance = true;
    boolean that_present_insurance = true;
    if (this_present_insurance || that_present_insurance) {
      if (!(this_present_insurance && that_present_insurance))
        return false;
      if (this.insurance != that.insurance)
        return false;
    }

    boolean this_present_weight = true;
    boolean that_present_weight = true;
    if (this_present_weight || that_present_weight) {
      if (!(this_present_weight && that_present_weight))
        return false;
      if (this.weight != that.weight)
        return false;
    }

    boolean this_present_airwayBillNo = true && this.isSetAirwayBillNo();
    boolean that_present_airwayBillNo = true && that.isSetAirwayBillNo();
    if (this_present_airwayBillNo || that_present_airwayBillNo) {
      if (!(this_present_airwayBillNo && that_present_airwayBillNo))
        return false;
      if (!this.airwayBillNo.equals(that.airwayBillNo))
        return false;
    }

    boolean this_present_provider = true && this.isSetProvider();
    boolean that_present_provider = true && that.isSetProvider();
    if (this_present_provider || that_present_provider) {
      if (!(this_present_provider && that_present_provider))
        return false;
      if (!this.provider.equals(that.provider))
        return false;
    }

    return true;
  }

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

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      _Fields fieldId = _Fields.findByThriftId(field.id);
      if (fieldId == null) {
        TProtocolUtil.skip(iprot, field.type);
      } else {
        switch (fieldId) {
          case ID:
            if (field.type == TType.I64) {
              this.id = iprot.readI64();
              setIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case ADDRESS:
            if (field.type == TType.STRING) {
              this.address = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case TRACKING_ID:
            if (field.type == TType.STRING) {
              this.trackingId = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case LINE_ITEMS:
            if (field.type == TType.LIST) {
              {
                TList _list17 = iprot.readListBegin();
                this.lineItems = new ArrayList<LineItem>(_list17.size);
                for (int _i18 = 0; _i18 < _list17.size; ++_i18)
                {
                  LineItem _elem19;
                  _elem19 = new LineItem();
                  _elem19.read(iprot);
                  this.lineItems.add(_elem19);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case STATUS:
            if (field.type == TType.I32) {
              this.status = ShipmentStatus.findByValue(iprot.readI32());
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SHIPMENT_TIMESTAMP:
            if (field.type == TType.I64) {
              this.shipmentTimestamp = iprot.readI64();
              setShipmentTimestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case DELIVERY_TIMESTAMP:
            if (field.type == TType.I64) {
              this.deliveryTimestamp = iprot.readI64();
              setDeliveryTimestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case VALUE:
            if (field.type == TType.DOUBLE) {
              this.value = iprot.readDouble();
              setValueIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case INSURANCE:
            if (field.type == TType.DOUBLE) {
              this.insurance = iprot.readDouble();
              setInsuranceIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case WEIGHT:
            if (field.type == TType.DOUBLE) {
              this.weight = iprot.readDouble();
              setWeightIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case AIRWAY_BILL_NO:
            if (field.type == TType.STRING) {
              this.airwayBillNo = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case PROVIDER:
            if (field.type == TType.STRING) {
              this.provider = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(ID_FIELD_DESC);
    oprot.writeI64(this.id);
    oprot.writeFieldEnd();
    if (this.address != null) {
      oprot.writeFieldBegin(ADDRESS_FIELD_DESC);
      oprot.writeString(this.address);
      oprot.writeFieldEnd();
    }
    if (this.trackingId != null) {
      oprot.writeFieldBegin(TRACKING_ID_FIELD_DESC);
      oprot.writeString(this.trackingId);
      oprot.writeFieldEnd();
    }
    if (this.lineItems != null) {
      oprot.writeFieldBegin(LINE_ITEMS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.lineItems.size()));
        for (LineItem _iter20 : this.lineItems)
        {
          _iter20.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.status != null) {
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
      oprot.writeI32(this.status.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(SHIPMENT_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.shipmentTimestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(DELIVERY_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.deliveryTimestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(VALUE_FIELD_DESC);
    oprot.writeDouble(this.value);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(INSURANCE_FIELD_DESC);
    oprot.writeDouble(this.insurance);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(WEIGHT_FIELD_DESC);
    oprot.writeDouble(this.weight);
    oprot.writeFieldEnd();
    if (this.airwayBillNo != null) {
      oprot.writeFieldBegin(AIRWAY_BILL_NO_FIELD_DESC);
      oprot.writeString(this.airwayBillNo);
      oprot.writeFieldEnd();
    }
    if (this.provider != null) {
      oprot.writeFieldBegin(PROVIDER_FIELD_DESC);
      oprot.writeString(this.provider);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("address:");
    if (this.address == null) {
      sb.append("null");
    } else {
      sb.append(this.address);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("trackingId:");
    if (this.trackingId == null) {
      sb.append("null");
    } else {
      sb.append(this.trackingId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("lineItems:");
    if (this.lineItems == null) {
      sb.append("null");
    } else {
      sb.append(this.lineItems);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      String status_name = status.name();
      if (status_name != null) {
        sb.append(status_name);
        sb.append(" (");
      }
      sb.append(this.status);
      if (status_name != null) {
        sb.append(")");
      }
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("shipmentTimestamp:");
    sb.append(this.shipmentTimestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("deliveryTimestamp:");
    sb.append(this.deliveryTimestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("value:");
    sb.append(this.value);
    first = false;
    if (!first) sb.append(", ");
    sb.append("insurance:");
    sb.append(this.insurance);
    first = false;
    if (!first) sb.append(", ");
    sb.append("weight:");
    sb.append(this.weight);
    first = false;
    if (!first) sb.append(", ");
    sb.append("airwayBillNo:");
    if (this.airwayBillNo == null) {
      sb.append("null");
    } else {
      sb.append(this.airwayBillNo);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("provider:");
    if (this.provider == null) {
      sb.append("null");
    } else {
      sb.append(this.provider);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}