/**
 * 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 CommitItem implements org.apache.thrift.TBase<CommitItem, CommitItem._Fields>, java.io.Serializable, Cloneable, Comparable<CommitItem> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CommitItem");

  private static final org.apache.thrift.protocol.TField REPO_URL_FIELD_DESC = new org.apache.thrift.protocol.TField("repoURL", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField REVISION_FIELD_DESC = new org.apache.thrift.protocol.TField("revision", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("path", org.apache.thrift.protocol.TType.STRING, (short)3);
  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)4);

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

  public @org.apache.thrift.annotation.Nullable java.lang.String repoURL; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String revision; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String path; // required
  /**
   * 
   * @see CommitItemChangeType
   */
  public @org.apache.thrift.annotation.Nullable CommitItemChangeType type; // 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 {
    REPO_URL((short)1, "repoURL"),
    REVISION((short)2, "revision"),
    PATH((short)3, "path"),
    /**
     * 
     * @see CommitItemChangeType
     */
    TYPE((short)4, "type");

    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: // REPO_URL
          return REPO_URL;
        case 2: // REVISION
          return REVISION;
        case 3: // PATH
          return PATH;
        case 4: // TYPE
          return TYPE;
        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.REPO_URL, new org.apache.thrift.meta_data.FieldMetaData("repoURL", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.REVISION, new org.apache.thrift.meta_data.FieldMetaData("revision", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.PATH, new org.apache.thrift.meta_data.FieldMetaData("path", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, CommitItemChangeType.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CommitItem.class, metaDataMap);
  }

  public CommitItem() {
  }

  public CommitItem(
    java.lang.String repoURL,
    java.lang.String revision,
    java.lang.String path,
    CommitItemChangeType type)
  {
    this();
    this.repoURL = repoURL;
    this.revision = revision;
    this.path = path;
    this.type = type;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public CommitItem(CommitItem other) {
    if (other.isSetRepoURL()) {
      this.repoURL = other.repoURL;
    }
    if (other.isSetRevision()) {
      this.revision = other.revision;
    }
    if (other.isSetPath()) {
      this.path = other.path;
    }
    if (other.isSetType()) {
      this.type = other.type;
    }
  }

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

  @Override
  public void clear() {
    this.repoURL = null;
    this.revision = null;
    this.path = null;
    this.type = null;
  }

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

  public CommitItem setRepoURL(@org.apache.thrift.annotation.Nullable java.lang.String repoURL) {
    this.repoURL = repoURL;
    return this;
  }

  public void unsetRepoURL() {
    this.repoURL = null;
  }

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

  public void setRepoURLIsSet(boolean value) {
    if (!value) {
      this.repoURL = null;
    }
  }

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

  public CommitItem setRevision(@org.apache.thrift.annotation.Nullable java.lang.String revision) {
    this.revision = revision;
    return this;
  }

  public void unsetRevision() {
    this.revision = null;
  }

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

  public void setRevisionIsSet(boolean value) {
    if (!value) {
      this.revision = null;
    }
  }

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

  public CommitItem setPath(@org.apache.thrift.annotation.Nullable java.lang.String path) {
    this.path = path;
    return this;
  }

  public void unsetPath() {
    this.path = null;
  }

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

  public void setPathIsSet(boolean value) {
    if (!value) {
      this.path = null;
    }
  }

  /**
   * 
   * @see CommitItemChangeType
   */
  @org.apache.thrift.annotation.Nullable
  public CommitItemChangeType getType() {
    return this.type;
  }

  /**
   * 
   * @see CommitItemChangeType
   */
  public CommitItem setType(@org.apache.thrift.annotation.Nullable CommitItemChangeType type) {
    this.type = type;
    return this;
  }

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

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

  public void setTypeIsSet(boolean value) {
    if (!value) {
      this.type = null;
    }
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case REPO_URL:
      if (value == null) {
        unsetRepoURL();
      } else {
        setRepoURL((java.lang.String)value);
      }
      break;

    case REVISION:
      if (value == null) {
        unsetRevision();
      } else {
        setRevision((java.lang.String)value);
      }
      break;

    case PATH:
      if (value == null) {
        unsetPath();
      } else {
        setPath((java.lang.String)value);
      }
      break;

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

    }
  }

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

    case REVISION:
      return getRevision();

    case PATH:
      return getPath();

    case TYPE:
      return getType();

    }
    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 REPO_URL:
      return isSetRepoURL();
    case REVISION:
      return isSetRevision();
    case PATH:
      return isSetPath();
    case TYPE:
      return isSetType();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_repoURL = true && this.isSetRepoURL();
    boolean that_present_repoURL = true && that.isSetRepoURL();
    if (this_present_repoURL || that_present_repoURL) {
      if (!(this_present_repoURL && that_present_repoURL))
        return false;
      if (!this.repoURL.equals(that.repoURL))
        return false;
    }

    boolean this_present_revision = true && this.isSetRevision();
    boolean that_present_revision = true && that.isSetRevision();
    if (this_present_revision || that_present_revision) {
      if (!(this_present_revision && that_present_revision))
        return false;
      if (!this.revision.equals(that.revision))
        return false;
    }

    boolean this_present_path = true && this.isSetPath();
    boolean that_present_path = true && that.isSetPath();
    if (this_present_path || that_present_path) {
      if (!(this_present_path && that_present_path))
        return false;
      if (!this.path.equals(that.path))
        return false;
    }

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

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetRepoURL()) ? 131071 : 524287);
    if (isSetRepoURL())
      hashCode = hashCode * 8191 + repoURL.hashCode();

    hashCode = hashCode * 8191 + ((isSetRevision()) ? 131071 : 524287);
    if (isSetRevision())
      hashCode = hashCode * 8191 + revision.hashCode();

    hashCode = hashCode * 8191 + ((isSetPath()) ? 131071 : 524287);
    if (isSetPath())
      hashCode = hashCode * 8191 + path.hashCode();

    hashCode = hashCode * 8191 + ((isSetType()) ? 131071 : 524287);
    if (isSetType())
      hashCode = hashCode * 8191 + type.getValue();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetRepoURL()).compareTo(other.isSetRepoURL());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRepoURL()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.repoURL, other.repoURL);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetRevision()).compareTo(other.isSetRevision());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetRevision()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.revision, other.revision);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetPath()).compareTo(other.isSetPath());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPath()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.path, other.path);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.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;
      }
    }
    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("CommitItem(");
    boolean first = true;

    sb.append("repoURL:");
    if (this.repoURL == null) {
      sb.append("null");
    } else {
      sb.append(this.repoURL);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("revision:");
    if (this.revision == null) {
      sb.append("null");
    } else {
      sb.append(this.revision);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("path:");
    if (this.path == null) {
      sb.append("null");
    } else {
      sb.append(this.path);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("type:");
    if (this.type == null) {
      sb.append("null");
    } else {
      sb.append(this.type);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    if (repoURL == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'repoURL' was not present! Struct: " + toString());
    }
    if (revision == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'revision' was not present! Struct: " + toString());
    }
    if (path == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'path' was not present! Struct: " + toString());
    }
    if (type == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString());
    }
    // 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, 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 CommitItemStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public CommitItemStandardScheme getScheme() {
      return new CommitItemStandardScheme();
    }
  }

  private static class CommitItemStandardScheme extends org.apache.thrift.scheme.StandardScheme<CommitItem> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, CommitItem 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: // REPO_URL
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.repoURL = iprot.readString();
              struct.setRepoURLIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // REVISION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.revision = iprot.readString();
              struct.setRevisionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // PATH
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.path = iprot.readString();
              struct.setPathIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.type = org.eclipse.hawk.service.api.CommitItemChangeType.findByValue(iprot.readI32());
              struct.setTypeIsSet(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, CommitItem struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.repoURL != null) {
        oprot.writeFieldBegin(REPO_URL_FIELD_DESC);
        oprot.writeString(struct.repoURL);
        oprot.writeFieldEnd();
      }
      if (struct.revision != null) {
        oprot.writeFieldBegin(REVISION_FIELD_DESC);
        oprot.writeString(struct.revision);
        oprot.writeFieldEnd();
      }
      if (struct.path != null) {
        oprot.writeFieldBegin(PATH_FIELD_DESC);
        oprot.writeString(struct.path);
        oprot.writeFieldEnd();
      }
      if (struct.type != null) {
        oprot.writeFieldBegin(TYPE_FIELD_DESC);
        oprot.writeI32(struct.type.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class CommitItemTupleScheme extends org.apache.thrift.scheme.TupleScheme<CommitItem> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, CommitItem struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      oprot.writeString(struct.repoURL);
      oprot.writeString(struct.revision);
      oprot.writeString(struct.path);
      oprot.writeI32(struct.type.getValue());
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, CommitItem struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      struct.repoURL = iprot.readString();
      struct.setRepoURLIsSet(true);
      struct.revision = iprot.readString();
      struct.setRevisionIsSet(true);
      struct.path = iprot.readString();
      struct.setPathIsSet(true);
      struct.type = org.eclipse.hawk.service.api.CommitItemChangeType.findByValue(iprot.readI32());
      struct.setTypeIsSet(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();
  }
}

