/**
 * Autogenerated by Thrift Compiler (0.13.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.eclipse.hawk.service.api;

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

  private static final org.apache.thrift.protocol.TField VCS_ITEM_FIELD_DESC = new org.apache.thrift.protocol.TField("vcsItem", org.apache.thrift.protocol.TType.STRUCT, (short)1);
  private static final org.apache.thrift.protocol.TField SOURCE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sourceId", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField TARGET_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("targetId", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField REF_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("refName", org.apache.thrift.protocol.TType.STRING, (short)4);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new HawkReferenceRemovalEventStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new HawkReferenceRemovalEventTupleSchemeFactory();

  public @org.apache.thrift.annotation.Nullable CommitItem vcsItem; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String sourceId; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String targetId; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String refName; // 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 {
    VCS_ITEM((short)1, "vcsItem"),
    SOURCE_ID((short)2, "sourceId"),
    TARGET_ID((short)3, "targetId"),
    REF_NAME((short)4, "refName");

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

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

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // VCS_ITEM
          return VCS_ITEM;
        case 2: // SOURCE_ID
          return SOURCE_ID;
        case 3: // TARGET_ID
          return TARGET_ID;
        case 4: // REF_NAME
          return REF_NAME;
        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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

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

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.VCS_ITEM, new org.apache.thrift.meta_data.FieldMetaData("vcsItem", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CommitItem.class)));
    tmpMap.put(_Fields.SOURCE_ID, new org.apache.thrift.meta_data.FieldMetaData("sourceId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TARGET_ID, new org.apache.thrift.meta_data.FieldMetaData("targetId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.REF_NAME, new org.apache.thrift.meta_data.FieldMetaData("refName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(HawkReferenceRemovalEvent.class, metaDataMap);
  }

  public HawkReferenceRemovalEvent() {
  }

  public HawkReferenceRemovalEvent(
    CommitItem vcsItem,
    java.lang.String sourceId,
    java.lang.String targetId,
    java.lang.String refName)
  {
    this();
    this.vcsItem = vcsItem;
    this.sourceId = sourceId;
    this.targetId = targetId;
    this.refName = refName;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public HawkReferenceRemovalEvent(HawkReferenceRemovalEvent other) {
    if (other.isSetVcsItem()) {
      this.vcsItem = new CommitItem(other.vcsItem);
    }
    if (other.isSetSourceId()) {
      this.sourceId = other.sourceId;
    }
    if (other.isSetTargetId()) {
      this.targetId = other.targetId;
    }
    if (other.isSetRefName()) {
      this.refName = other.refName;
    }
  }

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

  @Override
  public void clear() {
    this.vcsItem = null;
    this.sourceId = null;
    this.targetId = null;
    this.refName = null;
  }

  @org.apache.thrift.annotation.Nullable
  public CommitItem getVcsItem() {
    return this.vcsItem;
  }

  public HawkReferenceRemovalEvent setVcsItem(@org.apache.thrift.annotation.Nullable CommitItem vcsItem) {
    this.vcsItem = vcsItem;
    return this;
  }

  public void unsetVcsItem() {
    this.vcsItem = null;
  }

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

  public void setVcsItemIsSet(boolean value) {
    if (!value) {
      this.vcsItem = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getSourceId() {
    return this.sourceId;
  }

  public HawkReferenceRemovalEvent setSourceId(@org.apache.thrift.annotation.Nullable java.lang.String sourceId) {
    this.sourceId = sourceId;
    return this;
  }

  public void unsetSourceId() {
    this.sourceId = null;
  }

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

  public void setSourceIdIsSet(boolean value) {
    if (!value) {
      this.sourceId = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getTargetId() {
    return this.targetId;
  }

  public HawkReferenceRemovalEvent setTargetId(@org.apache.thrift.annotation.Nullable java.lang.String targetId) {
    this.targetId = targetId;
    return this;
  }

  public void unsetTargetId() {
    this.targetId = null;
  }

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

  public void setTargetIdIsSet(boolean value) {
    if (!value) {
      this.targetId = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getRefName() {
    return this.refName;
  }

  public HawkReferenceRemovalEvent setRefName(@org.apache.thrift.annotation.Nullable java.lang.String refName) {
    this.refName = refName;
    return this;
  }

  public void unsetRefName() {
    this.refName = null;
  }

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

  public void setRefNameIsSet(boolean value) {
    if (!value) {
      this.refName = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case VCS_ITEM:
      if (value == null) {
        unsetVcsItem();
      } else {
        setVcsItem((CommitItem)value);
      }
      break;

    case SOURCE_ID:
      if (value == null) {
        unsetSourceId();
      } else {
        setSourceId((java.lang.String)value);
      }
      break;

    case TARGET_ID:
      if (value == null) {
        unsetTargetId();
      } else {
        setTargetId((java.lang.String)value);
      }
      break;

    case REF_NAME:
      if (value == null) {
        unsetRefName();
      } else {
        setRefName((java.lang.String)value);
      }
      break;

    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case VCS_ITEM:
      return getVcsItem();

    case SOURCE_ID:
      return getSourceId();

    case TARGET_ID:
      return getTargetId();

    case REF_NAME:
      return getRefName();

    }
    throw new java.lang.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 java.lang.IllegalArgumentException();
    }

    switch (field) {
    case VCS_ITEM:
      return isSetVcsItem();
    case SOURCE_ID:
      return isSetSourceId();
    case TARGET_ID:
      return isSetTargetId();
    case REF_NAME:
      return isSetRefName();
    }
    throw new java.lang.IllegalStateException();
  }

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

  public boolean equals(HawkReferenceRemovalEvent that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_vcsItem = true && this.isSetVcsItem();
    boolean that_present_vcsItem = true && that.isSetVcsItem();
    if (this_present_vcsItem || that_present_vcsItem) {
      if (!(this_present_vcsItem && that_present_vcsItem))
        return false;
      if (!this.vcsItem.equals(that.vcsItem))
        return false;
    }

    boolean this_present_sourceId = true && this.isSetSourceId();
    boolean that_present_sourceId = true && that.isSetSourceId();
    if (this_present_sourceId || that_present_sourceId) {
      if (!(this_present_sourceId && that_present_sourceId))
        return false;
      if (!this.sourceId.equals(that.sourceId))
        return false;
    }

    boolean this_present_targetId = true && this.isSetTargetId();
    boolean that_present_targetId = true && that.isSetTargetId();
    if (this_present_targetId || that_present_targetId) {
      if (!(this_present_targetId && that_present_targetId))
        return false;
      if (!this.targetId.equals(that.targetId))
        return false;
    }

    boolean this_present_refName = true && this.isSetRefName();
    boolean that_present_refName = true && that.isSetRefName();
    if (this_present_refName || that_present_refName) {
      if (!(this_present_refName && that_present_refName))
        return false;
      if (!this.refName.equals(that.refName))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetVcsItem()) ? 131071 : 524287);
    if (isSetVcsItem())
      hashCode = hashCode * 8191 + vcsItem.hashCode();

    hashCode = hashCode * 8191 + ((isSetSourceId()) ? 131071 : 524287);
    if (isSetSourceId())
      hashCode = hashCode * 8191 + sourceId.hashCode();

    hashCode = hashCode * 8191 + ((isSetTargetId()) ? 131071 : 524287);
    if (isSetTargetId())
      hashCode = hashCode * 8191 + targetId.hashCode();

    hashCode = hashCode * 8191 + ((isSetRefName()) ? 131071 : 524287);
    if (isSetRefName())
      hashCode = hashCode * 8191 + refName.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetVcsItem()).compareTo(other.isSetVcsItem());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVcsItem()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.vcsItem, other.vcsItem);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetSourceId()).compareTo(other.isSetSourceId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSourceId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sourceId, other.sourceId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetTargetId()).compareTo(other.isSetTargetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTargetId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.targetId, other.targetId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetRefName()).compareTo(other.isSetRefName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRefName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.refName, other.refName);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

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

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

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("HawkReferenceRemovalEvent(");
    boolean first = true;

    sb.append("vcsItem:");
    if (this.vcsItem == null) {
      sb.append("null");
    } else {
      sb.append(this.vcsItem);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("sourceId:");
    if (this.sourceId == null) {
      sb.append("null");
    } else {
      sb.append(this.sourceId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("targetId:");
    if (this.targetId == null) {
      sb.append("null");
    } else {
      sb.append(this.targetId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("refName:");
    if (this.refName == null) {
      sb.append("null");
    } else {
      sb.append(this.refName);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    if (vcsItem == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'vcsItem' was not present! Struct: " + toString());
    }
    if (sourceId == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'sourceId' was not present! Struct: " + toString());
    }
    if (targetId == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'targetId' was not present! Struct: " + toString());
    }
    if (refName == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'refName' was not present! Struct: " + toString());
    }
    // check for sub-struct validity
    if (vcsItem != null) {
      vcsItem.validate();
    }
  }

  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, java.lang.ClassNotFoundException {
    try {
      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 HawkReferenceRemovalEventStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public HawkReferenceRemovalEventStandardScheme getScheme() {
      return new HawkReferenceRemovalEventStandardScheme();
    }
  }

  private static class HawkReferenceRemovalEventStandardScheme extends org.apache.thrift.scheme.StandardScheme<HawkReferenceRemovalEvent> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, HawkReferenceRemovalEvent 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: // VCS_ITEM
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.vcsItem = new CommitItem();
              struct.vcsItem.read(iprot);
              struct.setVcsItemIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // SOURCE_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.sourceId = iprot.readString();
              struct.setSourceIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // TARGET_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.targetId = iprot.readString();
              struct.setTargetIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // REF_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.refName = iprot.readString();
              struct.setRefNameIsSet(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, HawkReferenceRemovalEvent struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.vcsItem != null) {
        oprot.writeFieldBegin(VCS_ITEM_FIELD_DESC);
        struct.vcsItem.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.sourceId != null) {
        oprot.writeFieldBegin(SOURCE_ID_FIELD_DESC);
        oprot.writeString(struct.sourceId);
        oprot.writeFieldEnd();
      }
      if (struct.targetId != null) {
        oprot.writeFieldBegin(TARGET_ID_FIELD_DESC);
        oprot.writeString(struct.targetId);
        oprot.writeFieldEnd();
      }
      if (struct.refName != null) {
        oprot.writeFieldBegin(REF_NAME_FIELD_DESC);
        oprot.writeString(struct.refName);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class HawkReferenceRemovalEventTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public HawkReferenceRemovalEventTupleScheme getScheme() {
      return new HawkReferenceRemovalEventTupleScheme();
    }
  }

  private static class HawkReferenceRemovalEventTupleScheme extends org.apache.thrift.scheme.TupleScheme<HawkReferenceRemovalEvent> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, HawkReferenceRemovalEvent struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      struct.vcsItem.write(oprot);
      oprot.writeString(struct.sourceId);
      oprot.writeString(struct.targetId);
      oprot.writeString(struct.refName);
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, HawkReferenceRemovalEvent struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      struct.vcsItem = new CommitItem();
      struct.vcsItem.read(iprot);
      struct.setVcsItemIsSet(true);
      struct.sourceId = iprot.readString();
      struct.setSourceIdIsSet(true);
      struct.targetId = iprot.readString();
      struct.setTargetIdIsSet(true);
      struct.refName = iprot.readString();
      struct.setRefNameIsSet(true);
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}

