/**
 * Autogenerated by Thrift Compiler (0.10.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.navercorp.pinpoint.thrift.dto.command;

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

  private static final org.apache.thrift.protocol.TField THREAD_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("threadName", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField THREAD_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("threadId", org.apache.thrift.protocol.TType.I64, (short)2);
  private static final org.apache.thrift.protocol.TField THREAD_STATE_FIELD_DESC = new org.apache.thrift.protocol.TField("threadState", org.apache.thrift.protocol.TType.I32, (short)3);

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

  private java.lang.String threadName; // required
  private long threadId; // required
  private TThreadState threadState; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    THREAD_NAME((short)1, "threadName"),
    THREAD_ID((short)2, "threadId"),
    /**
     * 
     * @see TThreadState
     */
    THREAD_STATE((short)3, "threadState");

    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.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // THREAD_NAME
          return THREAD_NAME;
        case 2: // THREAD_ID
          return THREAD_ID;
        case 3: // THREAD_STATE
          return THREAD_STATE;
        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.
     */
    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 __THREADID_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.THREAD_STATE};
  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.THREAD_NAME, new org.apache.thrift.meta_data.FieldMetaData("threadName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.THREAD_ID, new org.apache.thrift.meta_data.FieldMetaData("threadId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.THREAD_STATE, new org.apache.thrift.meta_data.FieldMetaData("threadState", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TThreadState.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TThreadLightDump.class, metaDataMap);
  }

  public TThreadLightDump() {
  }

  public TThreadLightDump(
    java.lang.String threadName,
    long threadId)
  {
    this();
    this.threadName = threadName;
    this.threadId = threadId;
    setThreadIdIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TThreadLightDump(TThreadLightDump other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetThreadName()) {
      this.threadName = other.threadName;
    }
    this.threadId = other.threadId;
    if (other.isSetThreadState()) {
      this.threadState = other.threadState;
    }
  }

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

  @Override
  public void clear() {
    this.threadName = null;
    setThreadIdIsSet(false);
    this.threadId = 0;
    this.threadState = null;
  }

  public java.lang.String getThreadName() {
    return this.threadName;
  }

  public void setThreadName(java.lang.String threadName) {
    this.threadName = threadName;
  }

  public void unsetThreadName() {
    this.threadName = null;
  }

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

  public void setThreadNameIsSet(boolean value) {
    if (!value) {
      this.threadName = null;
    }
  }

  public long getThreadId() {
    return this.threadId;
  }

  public void setThreadId(long threadId) {
    this.threadId = threadId;
    setThreadIdIsSet(true);
  }

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

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

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

  /**
   * 
   * @see TThreadState
   */
  public TThreadState getThreadState() {
    return this.threadState;
  }

  /**
   * 
   * @see TThreadState
   */
  public void setThreadState(TThreadState threadState) {
    this.threadState = threadState;
  }

  public void unsetThreadState() {
    this.threadState = null;
  }

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

  public void setThreadStateIsSet(boolean value) {
    if (!value) {
      this.threadState = null;
    }
  }

  public void setFieldValue(_Fields field, java.lang.Object value) {
    switch (field) {
    case THREAD_NAME:
      if (value == null) {
        unsetThreadName();
      } else {
        setThreadName((java.lang.String)value);
      }
      break;

    case THREAD_ID:
      if (value == null) {
        unsetThreadId();
      } else {
        setThreadId((java.lang.Long)value);
      }
      break;

    case THREAD_STATE:
      if (value == null) {
        unsetThreadState();
      } else {
        setThreadState((TThreadState)value);
      }
      break;

    }
  }

  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case THREAD_NAME:
      return getThreadName();

    case THREAD_ID:
      return getThreadId();

    case THREAD_STATE:
      return getThreadState();

    }
    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 THREAD_NAME:
      return isSetThreadName();
    case THREAD_ID:
      return isSetThreadId();
    case THREAD_STATE:
      return isSetThreadState();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_threadName = true && this.isSetThreadName();
    boolean that_present_threadName = true && that.isSetThreadName();
    if (this_present_threadName || that_present_threadName) {
      if (!(this_present_threadName && that_present_threadName))
        return false;
      if (!this.threadName.equals(that.threadName))
        return false;
    }

    boolean this_present_threadId = true;
    boolean that_present_threadId = true;
    if (this_present_threadId || that_present_threadId) {
      if (!(this_present_threadId && that_present_threadId))
        return false;
      if (this.threadId != that.threadId)
        return false;
    }

    boolean this_present_threadState = true && this.isSetThreadState();
    boolean that_present_threadState = true && that.isSetThreadState();
    if (this_present_threadState || that_present_threadState) {
      if (!(this_present_threadState && that_present_threadState))
        return false;
      if (!this.threadState.equals(that.threadState))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetThreadName()) ? 131071 : 524287);
    if (isSetThreadName())
      hashCode = hashCode * 8191 + threadName.hashCode();

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

    hashCode = hashCode * 8191 + ((isSetThreadState()) ? 131071 : 524287);
    if (isSetThreadState())
      hashCode = hashCode * 8191 + threadState.getValue();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetThreadName()).compareTo(other.isSetThreadName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetThreadName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.threadName, other.threadName);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetThreadId()).compareTo(other.isSetThreadId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetThreadId()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.threadId, other.threadId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetThreadState()).compareTo(other.isSetThreadState());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetThreadState()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.threadState, other.threadState);
      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 {
    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("TThreadLightDump(");
    boolean first = true;

    sb.append("threadName:");
    if (this.threadName == null) {
      sb.append("null");
    } else {
      sb.append(this.threadName);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("threadId:");
    sb.append(this.threadId);
    first = false;
    if (isSetThreadState()) {
      if (!first) sb.append(", ");
      sb.append("threadState:");
      if (this.threadState == null) {
        sb.append("null");
      } else {
        sb.append(this.threadState);
      }
      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, 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 TThreadLightDumpStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TThreadLightDumpStandardScheme getScheme() {
      return new TThreadLightDumpStandardScheme();
    }
  }

  private static class TThreadLightDumpStandardScheme extends org.apache.thrift.scheme.StandardScheme<TThreadLightDump> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TThreadLightDump 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: // THREAD_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.threadName = iprot.readString();
              struct.setThreadNameIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // THREAD_ID
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.threadId = iprot.readI64();
              struct.setThreadIdIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // THREAD_STATE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.threadState = com.navercorp.pinpoint.thrift.dto.command.TThreadState.findByValue(iprot.readI32());
              struct.setThreadStateIsSet(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();
      struct.validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.threadName != null) {
        oprot.writeFieldBegin(THREAD_NAME_FIELD_DESC);
        oprot.writeString(struct.threadName);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(THREAD_ID_FIELD_DESC);
      oprot.writeI64(struct.threadId);
      oprot.writeFieldEnd();
      if (struct.threadState != null) {
        if (struct.isSetThreadState()) {
          oprot.writeFieldBegin(THREAD_STATE_FIELD_DESC);
          oprot.writeI32(struct.threadState.getValue());
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TThreadLightDumpTupleScheme extends org.apache.thrift.scheme.TupleScheme<TThreadLightDump> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TThreadLightDump struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetThreadName()) {
        optionals.set(0);
      }
      if (struct.isSetThreadId()) {
        optionals.set(1);
      }
      if (struct.isSetThreadState()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetThreadName()) {
        oprot.writeString(struct.threadName);
      }
      if (struct.isSetThreadId()) {
        oprot.writeI64(struct.threadId);
      }
      if (struct.isSetThreadState()) {
        oprot.writeI32(struct.threadState.getValue());
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TThreadLightDump struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        struct.threadName = iprot.readString();
        struct.setThreadNameIsSet(true);
      }
      if (incoming.get(1)) {
        struct.threadId = iprot.readI64();
        struct.setThreadIdIsSet(true);
      }
      if (incoming.get(2)) {
        struct.threadState = com.navercorp.pinpoint.thrift.dto.command.TThreadState.findByValue(iprot.readI32());
        struct.setThreadStateIsSet(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();
  }
}

