/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.opendaylight.netvirt.bgpmanager.thrift.gen;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-04-09")
public class Update implements org.apache.thrift.TBase<Update, Update._Fields>, java.io.Serializable, Cloneable, Comparable<Update> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Update");

  private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField RESERVED_FIELD_DESC = new org.apache.thrift.protocol.TField("reserved", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField PREFIXLEN_FIELD_DESC = new org.apache.thrift.protocol.TField("prefixlen", org.apache.thrift.protocol.TType.I32, (short)3);
  private static final org.apache.thrift.protocol.TField L3LABEL_FIELD_DESC = new org.apache.thrift.protocol.TField("l3label", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField L2LABEL_FIELD_DESC = new org.apache.thrift.protocol.TField("l2label", org.apache.thrift.protocol.TType.I32, (short)5);
  private static final org.apache.thrift.protocol.TField ETHTAG_FIELD_DESC = new org.apache.thrift.protocol.TField("ethtag", org.apache.thrift.protocol.TType.I32, (short)6);
  private static final org.apache.thrift.protocol.TField ESI_FIELD_DESC = new org.apache.thrift.protocol.TField("esi", org.apache.thrift.protocol.TType.STRING, (short)7);
  private static final org.apache.thrift.protocol.TField MACADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("macaddress", org.apache.thrift.protocol.TType.STRING, (short)8);
  private static final org.apache.thrift.protocol.TField RD_FIELD_DESC = new org.apache.thrift.protocol.TField("rd", org.apache.thrift.protocol.TType.STRING, (short)9);
  private static final org.apache.thrift.protocol.TField PREFIX_FIELD_DESC = new org.apache.thrift.protocol.TField("prefix", org.apache.thrift.protocol.TType.STRING, (short)10);
  private static final org.apache.thrift.protocol.TField NEXTHOP_FIELD_DESC = new org.apache.thrift.protocol.TField("nexthop", org.apache.thrift.protocol.TType.STRING, (short)11);
  private static final org.apache.thrift.protocol.TField ROUTERMAC_FIELD_DESC = new org.apache.thrift.protocol.TField("routermac", org.apache.thrift.protocol.TType.STRING, (short)12);

  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new UpdateStandardSchemeFactory());
    schemes.put(TupleScheme.class, new UpdateTupleSchemeFactory());
  }

  public int type; // required
  public int reserved; // required
  public int prefixlen; // required
  public int l3label; // required
  public int l2label; // required
  public int ethtag; // required
  public String esi; // required
  public String macaddress; // required
  public String rd; // required
  public String prefix; // required
  public String nexthop; // required
  public String routermac; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    TYPE((short)1, "type"),
    RESERVED((short)2, "reserved"),
    PREFIXLEN((short)3, "prefixlen"),
    L3LABEL((short)4, "l3label"),
    L2LABEL((short)5, "l2label"),
    ETHTAG((short)6, "ethtag"),
    ESI((short)7, "esi"),
    MACADDRESS((short)8, "macaddress"),
    RD((short)9, "rd"),
    PREFIX((short)10, "prefix"),
    NEXTHOP((short)11, "nexthop"),
    ROUTERMAC((short)12, "routermac");

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

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

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // TYPE
          return TYPE;
        case 2: // RESERVED
          return RESERVED;
        case 3: // PREFIXLEN
          return PREFIXLEN;
        case 4: // L3LABEL
          return L3LABEL;
        case 5: // L2LABEL
          return L2LABEL;
        case 6: // ETHTAG
          return ETHTAG;
        case 7: // ESI
          return ESI;
        case 8: // MACADDRESS
          return MACADDRESS;
        case 9: // RD
          return RD;
        case 10: // PREFIX
          return PREFIX;
        case 11: // NEXTHOP
          return NEXTHOP;
        case 12: // ROUTERMAC
          return ROUTERMAC;
        default:
          return null;
      }
    }

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

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

    private final short _thriftId;
    private final String _fieldName;

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

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __TYPE_ISSET_ID = 0;
  private static final int __RESERVED_ISSET_ID = 1;
  private static final int __PREFIXLEN_ISSET_ID = 2;
  private static final int __L3LABEL_ISSET_ID = 3;
  private static final int __L2LABEL_ISSET_ID = 4;
  private static final int __ETHTAG_ISSET_ID = 5;
  private byte __isset_bitfield = 0;
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.RESERVED, new org.apache.thrift.meta_data.FieldMetaData("reserved", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.PREFIXLEN, new org.apache.thrift.meta_data.FieldMetaData("prefixlen", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.L3LABEL, new org.apache.thrift.meta_data.FieldMetaData("l3label", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.L2LABEL, new org.apache.thrift.meta_data.FieldMetaData("l2label", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.ETHTAG, new org.apache.thrift.meta_data.FieldMetaData("ethtag", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.ESI, new org.apache.thrift.meta_data.FieldMetaData("esi", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.MACADDRESS, new org.apache.thrift.meta_data.FieldMetaData("macaddress", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.RD, new org.apache.thrift.meta_data.FieldMetaData("rd", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.PREFIX, new org.apache.thrift.meta_data.FieldMetaData("prefix", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.NEXTHOP, new org.apache.thrift.meta_data.FieldMetaData("nexthop", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.ROUTERMAC, new org.apache.thrift.meta_data.FieldMetaData("routermac", org.apache.thrift.TFieldRequirementType.DEFAULT,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Update.class, metaDataMap);
  }

  public Update() {
  }

  public Update(
    int type,
    int reserved,
    int prefixlen,
    int l3label,
    int l2label,
    int ethtag,
    String esi,
    String macaddress,
    String rd,
    String prefix,
    String nexthop,
    String routermac)
  {
    this();
    this.type = type;
    setTypeIsSet(true);
    this.reserved = reserved;
    setReservedIsSet(true);
    this.prefixlen = prefixlen;
    setPrefixlenIsSet(true);
    this.l3label = l3label;
    setL3labelIsSet(true);
    this.l2label = l2label;
    setL2labelIsSet(true);
    this.ethtag = ethtag;
    setEthtagIsSet(true);
    this.esi = esi;
    this.macaddress = macaddress;
    this.rd = rd;
    this.prefix = prefix;
    this.nexthop = nexthop;
    this.routermac = routermac;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Update(Update other) {
    __isset_bitfield = other.__isset_bitfield;
    this.type = other.type;
    this.reserved = other.reserved;
    this.prefixlen = other.prefixlen;
    this.l3label = other.l3label;
    this.l2label = other.l2label;
    this.ethtag = other.ethtag;
    if (other.isSetEsi()) {
      this.esi = other.esi;
    }
    if (other.isSetMacaddress()) {
      this.macaddress = other.macaddress;
    }
    if (other.isSetRd()) {
      this.rd = other.rd;
    }
    if (other.isSetPrefix()) {
      this.prefix = other.prefix;
    }
    if (other.isSetNexthop()) {
      this.nexthop = other.nexthop;
    }
    if (other.isSetRoutermac()) {
      this.routermac = other.routermac;
    }
  }

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

  @Override
  public void clear() {
    setTypeIsSet(false);
    this.type = 0;
    setReservedIsSet(false);
    this.reserved = 0;
    setPrefixlenIsSet(false);
    this.prefixlen = 0;
    setL3labelIsSet(false);
    this.l3label = 0;
    setL2labelIsSet(false);
    this.l2label = 0;
    setEthtagIsSet(false);
    this.ethtag = 0;
    this.esi = null;
    this.macaddress = null;
    this.rd = null;
    this.prefix = null;
    this.nexthop = null;
    this.routermac = null;
  }

  public int getType() {
    return this.type;
  }

  public Update setType(int type) {
    this.type = type;
    setTypeIsSet(true);
    return this;
  }

  public void unsetType() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TYPE_ISSET_ID);
  }

  /** Returns true if field type is set (has been assigned a value) and false otherwise */
  public boolean isSetType() {
    return EncodingUtils.testBit(__isset_bitfield, __TYPE_ISSET_ID);
  }

  public void setTypeIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TYPE_ISSET_ID, value);
  }

  public int getReserved() {
    return this.reserved;
  }

  public Update setReserved(int reserved) {
    this.reserved = reserved;
    setReservedIsSet(true);
    return this;
  }

  public void unsetReserved() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __RESERVED_ISSET_ID);
  }

  /** Returns true if field reserved is set (has been assigned a value) and false otherwise */
  public boolean isSetReserved() {
    return EncodingUtils.testBit(__isset_bitfield, __RESERVED_ISSET_ID);
  }

  public void setReservedIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __RESERVED_ISSET_ID, value);
  }

  public int getPrefixlen() {
    return this.prefixlen;
  }

  public Update setPrefixlen(int prefixlen) {
    this.prefixlen = prefixlen;
    setPrefixlenIsSet(true);
    return this;
  }

  public void unsetPrefixlen() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PREFIXLEN_ISSET_ID);
  }

  /** Returns true if field prefixlen is set (has been assigned a value) and false otherwise */
  public boolean isSetPrefixlen() {
    return EncodingUtils.testBit(__isset_bitfield, __PREFIXLEN_ISSET_ID);
  }

  public void setPrefixlenIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PREFIXLEN_ISSET_ID, value);
  }

  public int getL3label() {
    return this.l3label;
  }

  public Update setL3label(int l3label) {
    this.l3label = l3label;
    setL3labelIsSet(true);
    return this;
  }

  public void unsetL3label() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __L3LABEL_ISSET_ID);
  }

  /** Returns true if field l3label is set (has been assigned a value) and false otherwise */
  public boolean isSetL3label() {
    return EncodingUtils.testBit(__isset_bitfield, __L3LABEL_ISSET_ID);
  }

  public void setL3labelIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __L3LABEL_ISSET_ID, value);
  }

  public int getL2label() {
    return this.l2label;
  }

  public Update setL2label(int l2label) {
    this.l2label = l2label;
    setL2labelIsSet(true);
    return this;
  }

  public void unsetL2label() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __L2LABEL_ISSET_ID);
  }

  /** Returns true if field l2label is set (has been assigned a value) and false otherwise */
  public boolean isSetL2label() {
    return EncodingUtils.testBit(__isset_bitfield, __L2LABEL_ISSET_ID);
  }

  public void setL2labelIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __L2LABEL_ISSET_ID, value);
  }

  public int getEthtag() {
    return this.ethtag;
  }

  public Update setEthtag(int ethtag) {
    this.ethtag = ethtag;
    setEthtagIsSet(true);
    return this;
  }

  public void unsetEthtag() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ETHTAG_ISSET_ID);
  }

  /** Returns true if field ethtag is set (has been assigned a value) and false otherwise */
  public boolean isSetEthtag() {
    return EncodingUtils.testBit(__isset_bitfield, __ETHTAG_ISSET_ID);
  }

  public void setEthtagIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ETHTAG_ISSET_ID, value);
  }

  public String getEsi() {
    return this.esi;
  }

  public Update setEsi(String esi) {
    this.esi = esi;
    return this;
  }

  public void unsetEsi() {
    this.esi = null;
  }

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

  public void setEsiIsSet(boolean value) {
    if (!value) {
      this.esi = null;
    }
  }

  public String getMacaddress() {
    return this.macaddress;
  }

  public Update setMacaddress(String macaddress) {
    this.macaddress = macaddress;
    return this;
  }

  public void unsetMacaddress() {
    this.macaddress = null;
  }

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

  public void setMacaddressIsSet(boolean value) {
    if (!value) {
      this.macaddress = null;
    }
  }

  public String getRd() {
    return this.rd;
  }

  public Update setRd(String rd) {
    this.rd = rd;
    return this;
  }

  public void unsetRd() {
    this.rd = null;
  }

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

  public void setRdIsSet(boolean value) {
    if (!value) {
      this.rd = null;
    }
  }

  public String getPrefix() {
    return this.prefix;
  }

  public Update setPrefix(String prefix) {
    this.prefix = prefix;
    return this;
  }

  public void unsetPrefix() {
    this.prefix = null;
  }

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

  public void setPrefixIsSet(boolean value) {
    if (!value) {
      this.prefix = null;
    }
  }

  public String getNexthop() {
    return this.nexthop;
  }

  public Update setNexthop(String nexthop) {
    this.nexthop = nexthop;
    return this;
  }

  public void unsetNexthop() {
    this.nexthop = null;
  }

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

  public void setNexthopIsSet(boolean value) {
    if (!value) {
      this.nexthop = null;
    }
  }

  public String getRoutermac() {
    return this.routermac;
  }

  public Update setRoutermac(String routermac) {
    this.routermac = routermac;
    return this;
  }

  public void unsetRoutermac() {
    this.routermac = null;
  }

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

  public void setRoutermacIsSet(boolean value) {
    if (!value) {
      this.routermac = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case TYPE:
      if (value == null) {
        unsetType();
      } else {
        setType((Integer)value);
      }
      break;

    case RESERVED:
      if (value == null) {
        unsetReserved();
      } else {
        setReserved((Integer)value);
      }
      break;

    case PREFIXLEN:
      if (value == null) {
        unsetPrefixlen();
      } else {
        setPrefixlen((Integer)value);
      }
      break;

    case L3LABEL:
      if (value == null) {
        unsetL3label();
      } else {
        setL3label((Integer)value);
      }
      break;

    case L2LABEL:
      if (value == null) {
        unsetL2label();
      } else {
        setL2label((Integer)value);
      }
      break;

    case ETHTAG:
      if (value == null) {
        unsetEthtag();
      } else {
        setEthtag((Integer)value);
      }
      break;

    case ESI:
      if (value == null) {
        unsetEsi();
      } else {
        setEsi((String)value);
      }
      break;

    case MACADDRESS:
      if (value == null) {
        unsetMacaddress();
      } else {
        setMacaddress((String)value);
      }
      break;

    case RD:
      if (value == null) {
        unsetRd();
      } else {
        setRd((String)value);
      }
      break;

    case PREFIX:
      if (value == null) {
        unsetPrefix();
      } else {
        setPrefix((String)value);
      }
      break;

    case NEXTHOP:
      if (value == null) {
        unsetNexthop();
      } else {
        setNexthop((String)value);
      }
      break;

    case ROUTERMAC:
      if (value == null) {
        unsetRoutermac();
      } else {
        setRoutermac((String)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case TYPE:
      return getType();

    case RESERVED:
      return getReserved();

    case PREFIXLEN:
      return getPrefixlen();

    case L3LABEL:
      return getL3label();

    case L2LABEL:
      return getL2label();

    case ETHTAG:
      return getEthtag();

    case ESI:
      return getEsi();

    case MACADDRESS:
      return getMacaddress();

    case RD:
      return getRd();

    case PREFIX:
      return getPrefix();

    case NEXTHOP:
      return getNexthop();

    case ROUTERMAC:
      return getRoutermac();

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case TYPE:
      return isSetType();
    case RESERVED:
      return isSetReserved();
    case PREFIXLEN:
      return isSetPrefixlen();
    case L3LABEL:
      return isSetL3label();
    case L2LABEL:
      return isSetL2label();
    case ETHTAG:
      return isSetEthtag();
    case ESI:
      return isSetEsi();
    case MACADDRESS:
      return isSetMacaddress();
    case RD:
      return isSetRd();
    case PREFIX:
      return isSetPrefix();
    case NEXTHOP:
      return isSetNexthop();
    case ROUTERMAC:
      return isSetRoutermac();
    }
    throw new IllegalStateException();
  }

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

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

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

    boolean this_present_reserved = true;
    boolean that_present_reserved = true;
    if (this_present_reserved || that_present_reserved) {
      if (!(this_present_reserved && that_present_reserved))
        return false;
      if (this.reserved != that.reserved)
        return false;
    }

    boolean this_present_prefixlen = true;
    boolean that_present_prefixlen = true;
    if (this_present_prefixlen || that_present_prefixlen) {
      if (!(this_present_prefixlen && that_present_prefixlen))
        return false;
      if (this.prefixlen != that.prefixlen)
        return false;
    }

    boolean this_present_l3label = true;
    boolean that_present_l3label = true;
    if (this_present_l3label || that_present_l3label) {
      if (!(this_present_l3label && that_present_l3label))
        return false;
      if (this.l3label != that.l3label)
        return false;
    }

    boolean this_present_l2label = true;
    boolean that_present_l2label = true;
    if (this_present_l2label || that_present_l2label) {
      if (!(this_present_l2label && that_present_l2label))
        return false;
      if (this.l2label != that.l2label)
        return false;
    }

    boolean this_present_ethtag = true;
    boolean that_present_ethtag = true;
    if (this_present_ethtag || that_present_ethtag) {
      if (!(this_present_ethtag && that_present_ethtag))
        return false;
      if (this.ethtag != that.ethtag)
        return false;
    }

    boolean this_present_esi = true && this.isSetEsi();
    boolean that_present_esi = true && that.isSetEsi();
    if (this_present_esi || that_present_esi) {
      if (!(this_present_esi && that_present_esi))
        return false;
      if (!this.esi.equals(that.esi))
        return false;
    }

    boolean this_present_macaddress = true && this.isSetMacaddress();
    boolean that_present_macaddress = true && that.isSetMacaddress();
    if (this_present_macaddress || that_present_macaddress) {
      if (!(this_present_macaddress && that_present_macaddress))
        return false;
      if (!this.macaddress.equals(that.macaddress))
        return false;
    }

    boolean this_present_rd = true && this.isSetRd();
    boolean that_present_rd = true && that.isSetRd();
    if (this_present_rd || that_present_rd) {
      if (!(this_present_rd && that_present_rd))
        return false;
      if (!this.rd.equals(that.rd))
        return false;
    }

    boolean this_present_prefix = true && this.isSetPrefix();
    boolean that_present_prefix = true && that.isSetPrefix();
    if (this_present_prefix || that_present_prefix) {
      if (!(this_present_prefix && that_present_prefix))
        return false;
      if (!this.prefix.equals(that.prefix))
        return false;
    }

    boolean this_present_nexthop = true && this.isSetNexthop();
    boolean that_present_nexthop = true && that.isSetNexthop();
    if (this_present_nexthop || that_present_nexthop) {
      if (!(this_present_nexthop && that_present_nexthop))
        return false;
      if (!this.nexthop.equals(that.nexthop))
        return false;
    }

    boolean this_present_routermac = true && this.isSetRoutermac();
    boolean that_present_routermac = true && that.isSetRoutermac();
    if (this_present_routermac || that_present_routermac) {
      if (!(this_present_routermac && that_present_routermac))
        return false;
      if (!this.routermac.equals(that.routermac))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List<Object> list = new ArrayList<Object>();

    boolean present_type = true;
    list.add(present_type);
    if (present_type)
      list.add(type);

    boolean present_reserved = true;
    list.add(present_reserved);
    if (present_reserved)
      list.add(reserved);

    boolean present_prefixlen = true;
    list.add(present_prefixlen);
    if (present_prefixlen)
      list.add(prefixlen);

    boolean present_l3label = true;
    list.add(present_l3label);
    if (present_l3label)
      list.add(l3label);

    boolean present_l2label = true;
    list.add(present_l2label);
    if (present_l2label)
      list.add(l2label);

    boolean present_ethtag = true;
    list.add(present_ethtag);
    if (present_ethtag)
      list.add(ethtag);

    boolean present_esi = true && (isSetEsi());
    list.add(present_esi);
    if (present_esi)
      list.add(esi);

    boolean present_macaddress = true && (isSetMacaddress());
    list.add(present_macaddress);
    if (present_macaddress)
      list.add(macaddress);

    boolean present_rd = true && (isSetRd());
    list.add(present_rd);
    if (present_rd)
      list.add(rd);

    boolean present_prefix = true && (isSetPrefix());
    list.add(present_prefix);
    if (present_prefix)
      list.add(prefix);

    boolean present_nexthop = true && (isSetNexthop());
    list.add(present_nexthop);
    if (present_nexthop)
      list.add(nexthop);

    boolean present_routermac = true && (isSetRoutermac());
    list.add(present_routermac);
    if (present_routermac)
      list.add(routermac);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetReserved()).compareTo(other.isSetReserved());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetReserved()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.reserved, other.reserved);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPrefixlen()).compareTo(other.isSetPrefixlen());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrefixlen()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.prefixlen, other.prefixlen);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetL3label()).compareTo(other.isSetL3label());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetL3label()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.l3label, other.l3label);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetL2label()).compareTo(other.isSetL2label());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetL2label()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.l2label, other.l2label);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEthtag()).compareTo(other.isSetEthtag());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEthtag()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ethtag, other.ethtag);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEsi()).compareTo(other.isSetEsi());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEsi()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.esi, other.esi);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMacaddress()).compareTo(other.isSetMacaddress());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMacaddress()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.macaddress, other.macaddress);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRd()).compareTo(other.isSetRd());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRd()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.rd, other.rd);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPrefix()).compareTo(other.isSetPrefix());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrefix()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.prefix, other.prefix);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNexthop()).compareTo(other.isSetNexthop());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNexthop()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nexthop, other.nexthop);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetRoutermac()).compareTo(other.isSetRoutermac());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRoutermac()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.routermac, other.routermac);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

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

    sb.append("type:");
    sb.append(this.type);
    first = false;
    if (!first) sb.append(", ");
    sb.append("reserved:");
    sb.append(this.reserved);
    first = false;
    if (!first) sb.append(", ");
    sb.append("prefixlen:");
    sb.append(this.prefixlen);
    first = false;
    if (!first) sb.append(", ");
    sb.append("l3label:");
    sb.append(this.l3label);
    first = false;
    if (!first) sb.append(", ");
    sb.append("l2label:");
    sb.append(this.l2label);
    first = false;
    if (!first) sb.append(", ");
    sb.append("ethtag:");
    sb.append(this.ethtag);
    first = false;
    if (!first) sb.append(", ");
    sb.append("esi:");
    if (this.esi == null) {
      sb.append("null");
    } else {
      sb.append(this.esi);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("macaddress:");
    if (this.macaddress == null) {
      sb.append("null");
    } else {
      sb.append(this.macaddress);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("rd:");
    if (this.rd == null) {
      sb.append("null");
    } else {
      sb.append(this.rd);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("prefix:");
    if (this.prefix == null) {
      sb.append("null");
    } else {
      sb.append(this.prefix);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("nexthop:");
    if (this.nexthop == null) {
      sb.append("null");
    } else {
      sb.append(this.nexthop);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("routermac:");
    if (this.routermac == null) {
      sb.append("null");
    } else {
      sb.append(this.routermac);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class UpdateStandardSchemeFactory implements SchemeFactory {
    public UpdateStandardScheme getScheme() {
      return new UpdateStandardScheme();
    }
  }

  private static class UpdateStandardScheme extends StandardScheme<Update> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, Update struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.type = iprot.readI32();
              struct.setTypeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // RESERVED
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.reserved = iprot.readI32();
              struct.setReservedIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // PREFIXLEN
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.prefixlen = iprot.readI32();
              struct.setPrefixlenIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // L3LABEL
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.l3label = iprot.readI32();
              struct.setL3labelIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // L2LABEL
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.l2label = iprot.readI32();
              struct.setL2labelIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // ETHTAG
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.ethtag = iprot.readI32();
              struct.setEthtagIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // ESI
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.esi = iprot.readString();
              struct.setEsiIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // MACADDRESS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.macaddress = iprot.readString();
              struct.setMacaddressIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 9: // RD
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.rd = iprot.readString();
              struct.setRdIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 10: // PREFIX
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.prefix = iprot.readString();
              struct.setPrefixIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 11: // NEXTHOP
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.nexthop = iprot.readString();
              struct.setNexthopIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 12: // ROUTERMAC
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.routermac = iprot.readString();
              struct.setRoutermacIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, Update struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
      oprot.writeI32(struct.type);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(RESERVED_FIELD_DESC);
      oprot.writeI32(struct.reserved);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(PREFIXLEN_FIELD_DESC);
      oprot.writeI32(struct.prefixlen);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(L3LABEL_FIELD_DESC);
      oprot.writeI32(struct.l3label);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(L2LABEL_FIELD_DESC);
      oprot.writeI32(struct.l2label);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ETHTAG_FIELD_DESC);
      oprot.writeI32(struct.ethtag);
      oprot.writeFieldEnd();
      if (struct.esi != null) {
        oprot.writeFieldBegin(ESI_FIELD_DESC);
        oprot.writeString(struct.esi);
        oprot.writeFieldEnd();
      }
      if (struct.macaddress != null) {
        oprot.writeFieldBegin(MACADDRESS_FIELD_DESC);
        oprot.writeString(struct.macaddress);
        oprot.writeFieldEnd();
      }
      if (struct.rd != null) {
        oprot.writeFieldBegin(RD_FIELD_DESC);
        oprot.writeString(struct.rd);
        oprot.writeFieldEnd();
      }
      if (struct.prefix != null) {
        oprot.writeFieldBegin(PREFIX_FIELD_DESC);
        oprot.writeString(struct.prefix);
        oprot.writeFieldEnd();
      }
      if (struct.nexthop != null) {
        oprot.writeFieldBegin(NEXTHOP_FIELD_DESC);
        oprot.writeString(struct.nexthop);
        oprot.writeFieldEnd();
      }
      if (struct.routermac != null) {
        oprot.writeFieldBegin(ROUTERMAC_FIELD_DESC);
        oprot.writeString(struct.routermac);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class UpdateTupleSchemeFactory implements SchemeFactory {
    public UpdateTupleScheme getScheme() {
      return new UpdateTupleScheme();
    }
  }

  private static class UpdateTupleScheme extends TupleScheme<Update> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, Update struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetType()) {
        optionals.set(0);
      }
      if (struct.isSetReserved()) {
        optionals.set(1);
      }
      if (struct.isSetPrefixlen()) {
        optionals.set(2);
      }
      if (struct.isSetL3label()) {
        optionals.set(3);
      }
      if (struct.isSetL2label()) {
        optionals.set(4);
      }
      if (struct.isSetEthtag()) {
        optionals.set(5);
      }
      if (struct.isSetEsi()) {
        optionals.set(6);
      }
      if (struct.isSetMacaddress()) {
        optionals.set(7);
      }
      if (struct.isSetRd()) {
        optionals.set(8);
      }
      if (struct.isSetPrefix()) {
        optionals.set(9);
      }
      if (struct.isSetNexthop()) {
        optionals.set(10);
      }
      if (struct.isSetRoutermac()) {
        optionals.set(11);
      }
      oprot.writeBitSet(optionals, 12);
      if (struct.isSetType()) {
        oprot.writeI32(struct.type);
      }
      if (struct.isSetReserved()) {
        oprot.writeI32(struct.reserved);
      }
      if (struct.isSetPrefixlen()) {
        oprot.writeI32(struct.prefixlen);
      }
      if (struct.isSetL3label()) {
        oprot.writeI32(struct.l3label);
      }
      if (struct.isSetL2label()) {
        oprot.writeI32(struct.l2label);
      }
      if (struct.isSetEthtag()) {
        oprot.writeI32(struct.ethtag);
      }
      if (struct.isSetEsi()) {
        oprot.writeString(struct.esi);
      }
      if (struct.isSetMacaddress()) {
        oprot.writeString(struct.macaddress);
      }
      if (struct.isSetRd()) {
        oprot.writeString(struct.rd);
      }
      if (struct.isSetPrefix()) {
        oprot.writeString(struct.prefix);
      }
      if (struct.isSetNexthop()) {
        oprot.writeString(struct.nexthop);
      }
      if (struct.isSetRoutermac()) {
        oprot.writeString(struct.routermac);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, Update struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(12);
      if (incoming.get(0)) {
        struct.type = iprot.readI32();
        struct.setTypeIsSet(true);
      }
      if (incoming.get(1)) {
        struct.reserved = iprot.readI32();
        struct.setReservedIsSet(true);
      }
      if (incoming.get(2)) {
        struct.prefixlen = iprot.readI32();
        struct.setPrefixlenIsSet(true);
      }
      if (incoming.get(3)) {
        struct.l3label = iprot.readI32();
        struct.setL3labelIsSet(true);
      }
      if (incoming.get(4)) {
        struct.l2label = iprot.readI32();
        struct.setL2labelIsSet(true);
      }
      if (incoming.get(5)) {
        struct.ethtag = iprot.readI32();
        struct.setEthtagIsSet(true);
      }
      if (incoming.get(6)) {
        struct.esi = iprot.readString();
        struct.setEsiIsSet(true);
      }
      if (incoming.get(7)) {
        struct.macaddress = iprot.readString();
        struct.setMacaddressIsSet(true);
      }
      if (incoming.get(8)) {
        struct.rd = iprot.readString();
        struct.setRdIsSet(true);
      }
      if (incoming.get(9)) {
        struct.prefix = iprot.readString();
        struct.setPrefixIsSet(true);
      }
      if (incoming.get(10)) {
        struct.nexthop = iprot.readString();
        struct.setNexthopIsSet(true);
      }
      if (incoming.get(11)) {
        struct.routermac = iprot.readString();
        struct.setRoutermacIsSet(true);
      }
    }
  }

}

