All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yag.ipc.RequestHeader Maven / Gradle / Ivy

There is a newer version: 0.18.3
Show newest version
/**
 * Autogenerated by Thrift Compiler (0.12.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.github.yag.ipc;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
//Disable this for JDK9+ @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2020-05-11")
public class RequestHeader implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RequestHeader");

  private static final org.apache.thrift.protocol.TField CALL_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("callId", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField CALL_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("callType", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField CONTENT_LENGTH_FIELD_DESC = new org.apache.thrift.protocol.TField("contentLength", org.apache.thrift.protocol.TType.I32, (short)3);

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

  public long callId; // required
  public @org.apache.thrift.annotation.Nullable java.lang.String callType; // required
  public int contentLength; // 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 {
    CALL_ID((short)1, "callId"),
    CALL_TYPE((short)2, "callType"),
    CONTENT_LENGTH((short)3, "contentLength");

    private static final java.util.Map byName = new java.util.HashMap();

    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: // CALL_ID
          return CALL_ID;
        case 2: // CALL_TYPE
          return CALL_TYPE;
        case 3: // CONTENT_LENGTH
          return CONTENT_LENGTH;
        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
  private static final int __CALLID_ISSET_ID = 0;
  private static final int __CONTENTLENGTH_ISSET_ID = 1;
  private byte __isset_bitfield = 0;
  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.CALL_ID, new org.apache.thrift.meta_data.FieldMetaData("callId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.CALL_TYPE, new org.apache.thrift.meta_data.FieldMetaData("callType", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.CONTENT_LENGTH, new org.apache.thrift.meta_data.FieldMetaData("contentLength", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RequestHeader.class, metaDataMap);
  }

  public RequestHeader() {
  }

  public RequestHeader(
    long callId,
    java.lang.String callType,
    int contentLength)
  {
    this();
    this.callId = callId;
    setCallIdIsSet(true);
    this.callType = callType;
    this.contentLength = contentLength;
    setContentLengthIsSet(true);
  }

  /**
   * Performs a deep copy on other.
   */
  public RequestHeader(RequestHeader other) {
    __isset_bitfield = other.__isset_bitfield;
    this.callId = other.callId;
    if (other.isSetCallType()) {
      this.callType = other.callType;
    }
    this.contentLength = other.contentLength;
  }

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

  @Override
  public void clear() {
    setCallIdIsSet(false);
    this.callId = 0;
    this.callType = null;
    setContentLengthIsSet(false);
    this.contentLength = 0;
  }

  public long getCallId() {
    return this.callId;
  }

  public RequestHeader setCallId(long callId) {
    this.callId = callId;
    setCallIdIsSet(true);
    return this;
  }

  public void unsetCallId() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CALLID_ISSET_ID);
  }

  /** Returns true if field callId is set (has been assigned a value) and false otherwise */
  public boolean isSetCallId() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CALLID_ISSET_ID);
  }

  public void setCallIdIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CALLID_ISSET_ID, value);
  }

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

  public RequestHeader setCallType(@org.apache.thrift.annotation.Nullable java.lang.String callType) {
    this.callType = callType;
    return this;
  }

  public void unsetCallType() {
    this.callType = null;
  }

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

  public void setCallTypeIsSet(boolean value) {
    if (!value) {
      this.callType = null;
    }
  }

  public int getContentLength() {
    return this.contentLength;
  }

  public RequestHeader setContentLength(int contentLength) {
    this.contentLength = contentLength;
    setContentLengthIsSet(true);
    return this;
  }

  public void unsetContentLength() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CONTENTLENGTH_ISSET_ID);
  }

  /** Returns true if field contentLength is set (has been assigned a value) and false otherwise */
  public boolean isSetContentLength() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CONTENTLENGTH_ISSET_ID);
  }

  public void setContentLengthIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CONTENTLENGTH_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case CALL_ID:
      if (value == null) {
        unsetCallId();
      } else {
        setCallId((java.lang.Long)value);
      }
      break;

    case CALL_TYPE:
      if (value == null) {
        unsetCallType();
      } else {
        setCallType((java.lang.String)value);
      }
      break;

    case CONTENT_LENGTH:
      if (value == null) {
        unsetContentLength();
      } else {
        setContentLength((java.lang.Integer)value);
      }
      break;

    }
  }

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

    case CALL_TYPE:
      return getCallType();

    case CONTENT_LENGTH:
      return getContentLength();

    }
    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 CALL_ID:
      return isSetCallId();
    case CALL_TYPE:
      return isSetCallType();
    case CONTENT_LENGTH:
      return isSetContentLength();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_callId = true;
    boolean that_present_callId = true;
    if (this_present_callId || that_present_callId) {
      if (!(this_present_callId && that_present_callId))
        return false;
      if (this.callId != that.callId)
        return false;
    }

    boolean this_present_callType = true && this.isSetCallType();
    boolean that_present_callType = true && that.isSetCallType();
    if (this_present_callType || that_present_callType) {
      if (!(this_present_callType && that_present_callType))
        return false;
      if (!this.callType.equals(that.callType))
        return false;
    }

    boolean this_present_contentLength = true;
    boolean that_present_contentLength = true;
    if (this_present_contentLength || that_present_contentLength) {
      if (!(this_present_contentLength && that_present_contentLength))
        return false;
      if (this.contentLength != that.contentLength)
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(callId);

    hashCode = hashCode * 8191 + ((isSetCallType()) ? 131071 : 524287);
    if (isSetCallType())
      hashCode = hashCode * 8191 + callType.hashCode();

    hashCode = hashCode * 8191 + contentLength;

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetCallId()).compareTo(other.isSetCallId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCallId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.callId, other.callId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetCallType()).compareTo(other.isSetCallType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCallType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.callType, other.callType);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetContentLength()).compareTo(other.isSetContentLength());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetContentLength()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.contentLength, other.contentLength);
      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("RequestHeader(");
    boolean first = true;

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

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // alas, we cannot check 'callId' because it's a primitive and you chose the non-beans generator.
    if (callType == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'callType' was not present! Struct: " + toString());
    }
    // alas, we cannot check 'contentLength' because it's a primitive and you chose the non-beans generator.
    // 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 {
      // 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 RequestHeaderStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public RequestHeaderStandardScheme getScheme() {
      return new RequestHeaderStandardScheme();
    }
  }

  private static class RequestHeaderStandardScheme extends org.apache.thrift.scheme.StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, RequestHeader 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: // CALL_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.callId = iprot.readI64();
              struct.setCallIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // CALL_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.callType = iprot.readString();
              struct.setCallTypeIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // CONTENT_LENGTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.contentLength = iprot.readI32();
              struct.setContentLengthIsSet(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
      if (!struct.isSetCallId()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'callId' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetContentLength()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'contentLength' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(CALL_ID_FIELD_DESC);
      oprot.writeI64(struct.callId);
      oprot.writeFieldEnd();
      if (struct.callType != null) {
        oprot.writeFieldBegin(CALL_TYPE_FIELD_DESC);
        oprot.writeString(struct.callType);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(CONTENT_LENGTH_FIELD_DESC);
      oprot.writeI32(struct.contentLength);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class RequestHeaderTupleScheme extends org.apache.thrift.scheme.TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, RequestHeader struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      oprot.writeI64(struct.callId);
      oprot.writeString(struct.callType);
      oprot.writeI32(struct.contentLength);
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, RequestHeader struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      struct.callId = iprot.readI64();
      struct.setCallIdIsSet(true);
      struct.callType = iprot.readString();
      struct.setCallTypeIsSet(true);
      struct.contentLength = iprot.readI32();
      struct.setContentLengthIsSet(true);
    }
  }

  private static  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();
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy