/**
 * 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.flink;

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

  private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.I16, (short)1);
  private static final org.apache.thrift.protocol.TField VM_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("vmVersion", org.apache.thrift.protocol.TType.STRING, (short)2);
  private static final org.apache.thrift.protocol.TField GC_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("gcType", org.apache.thrift.protocol.TType.I32, (short)3);

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

  private short version; // required
  private java.lang.String vmVersion; // optional
  private TFJvmGcType gcType; // 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 {
    VERSION((short)1, "version"),
    VM_VERSION((short)2, "vmVersion"),
    /**
     * 
     * @see TFJvmGcType
     */
    GC_TYPE((short)3, "gcType");

    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: // VERSION
          return VERSION;
        case 2: // VM_VERSION
          return VM_VERSION;
        case 3: // GC_TYPE
          return GC_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.
     */
    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 __VERSION_ISSET_ID = 0;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.VM_VERSION,_Fields.GC_TYPE};
  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.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    tmpMap.put(_Fields.VM_VERSION, new org.apache.thrift.meta_data.FieldMetaData("vmVersion", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.GC_TYPE, new org.apache.thrift.meta_data.FieldMetaData("gcType", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TFJvmGcType.class)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TFJvmInfo.class, metaDataMap);
  }

  public TFJvmInfo() {
    this.version = (short)0;

    this.gcType = com.navercorp.pinpoint.thrift.dto.flink.TFJvmGcType.UNKNOWN;

  }

  public TFJvmInfo(
    short version)
  {
    this();
    this.version = version;
    setVersionIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TFJvmInfo(TFJvmInfo other) {
    __isset_bitfield = other.__isset_bitfield;
    this.version = other.version;
    if (other.isSetVmVersion()) {
      this.vmVersion = other.vmVersion;
    }
    if (other.isSetGcType()) {
      this.gcType = other.gcType;
    }
  }

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

  @Override
  public void clear() {
    this.version = (short)0;

    this.vmVersion = null;
    this.gcType = com.navercorp.pinpoint.thrift.dto.flink.TFJvmGcType.UNKNOWN;

  }

  public short getVersion() {
    return this.version;
  }

  public void setVersion(short version) {
    this.version = version;
    setVersionIsSet(true);
  }

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

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

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

  public java.lang.String getVmVersion() {
    return this.vmVersion;
  }

  public void setVmVersion(java.lang.String vmVersion) {
    this.vmVersion = vmVersion;
  }

  public void unsetVmVersion() {
    this.vmVersion = null;
  }

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

  public void setVmVersionIsSet(boolean value) {
    if (!value) {
      this.vmVersion = null;
    }
  }

  /**
   * 
   * @see TFJvmGcType
   */
  public TFJvmGcType getGcType() {
    return this.gcType;
  }

  /**
   * 
   * @see TFJvmGcType
   */
  public void setGcType(TFJvmGcType gcType) {
    this.gcType = gcType;
  }

  public void unsetGcType() {
    this.gcType = null;
  }

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

  public void setGcTypeIsSet(boolean value) {
    if (!value) {
      this.gcType = null;
    }
  }

  public void setFieldValue(_Fields field, java.lang.Object value) {
    switch (field) {
    case VERSION:
      if (value == null) {
        unsetVersion();
      } else {
        setVersion((java.lang.Short)value);
      }
      break;

    case VM_VERSION:
      if (value == null) {
        unsetVmVersion();
      } else {
        setVmVersion((java.lang.String)value);
      }
      break;

    case GC_TYPE:
      if (value == null) {
        unsetGcType();
      } else {
        setGcType((TFJvmGcType)value);
      }
      break;

    }
  }

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

    case VM_VERSION:
      return getVmVersion();

    case GC_TYPE:
      return getGcType();

    }
    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 VERSION:
      return isSetVersion();
    case VM_VERSION:
      return isSetVmVersion();
    case GC_TYPE:
      return isSetGcType();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_version = true;
    boolean that_present_version = true;
    if (this_present_version || that_present_version) {
      if (!(this_present_version && that_present_version))
        return false;
      if (this.version != that.version)
        return false;
    }

    boolean this_present_vmVersion = true && this.isSetVmVersion();
    boolean that_present_vmVersion = true && that.isSetVmVersion();
    if (this_present_vmVersion || that_present_vmVersion) {
      if (!(this_present_vmVersion && that_present_vmVersion))
        return false;
      if (!this.vmVersion.equals(that.vmVersion))
        return false;
    }

    boolean this_present_gcType = true && this.isSetGcType();
    boolean that_present_gcType = true && that.isSetGcType();
    if (this_present_gcType || that_present_gcType) {
      if (!(this_present_gcType && that_present_gcType))
        return false;
      if (!this.gcType.equals(that.gcType))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + version;

    hashCode = hashCode * 8191 + ((isSetVmVersion()) ? 131071 : 524287);
    if (isSetVmVersion())
      hashCode = hashCode * 8191 + vmVersion.hashCode();

    hashCode = hashCode * 8191 + ((isSetGcType()) ? 131071 : 524287);
    if (isSetGcType())
      hashCode = hashCode * 8191 + gcType.getValue();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVersion()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetVmVersion()).compareTo(other.isSetVmVersion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVmVersion()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.vmVersion, other.vmVersion);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetGcType()).compareTo(other.isSetGcType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGcType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gcType, other.gcType);
      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("TFJvmInfo(");
    boolean first = true;

    sb.append("version:");
    sb.append(this.version);
    first = false;
    if (isSetVmVersion()) {
      if (!first) sb.append(", ");
      sb.append("vmVersion:");
      if (this.vmVersion == null) {
        sb.append("null");
      } else {
        sb.append(this.vmVersion);
      }
      first = false;
    }
    if (isSetGcType()) {
      if (!first) sb.append(", ");
      sb.append("gcType:");
      if (this.gcType == null) {
        sb.append("null");
      } else {
        sb.append(this.gcType);
      }
      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 TFJvmInfoStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TFJvmInfoStandardScheme getScheme() {
      return new TFJvmInfoStandardScheme();
    }
  }

  private static class TFJvmInfoStandardScheme extends org.apache.thrift.scheme.StandardScheme<TFJvmInfo> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TFJvmInfo 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: // VERSION
            if (schemeField.type == org.apache.thrift.protocol.TType.I16) {
              struct.version = iprot.readI16();
              struct.setVersionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // VM_VERSION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.vmVersion = iprot.readString();
              struct.setVmVersionIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // GC_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.gcType = com.navercorp.pinpoint.thrift.dto.flink.TFJvmGcType.findByValue(iprot.readI32());
              struct.setGcTypeIsSet(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, TFJvmInfo struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(VERSION_FIELD_DESC);
      oprot.writeI16(struct.version);
      oprot.writeFieldEnd();
      if (struct.vmVersion != null) {
        if (struct.isSetVmVersion()) {
          oprot.writeFieldBegin(VM_VERSION_FIELD_DESC);
          oprot.writeString(struct.vmVersion);
          oprot.writeFieldEnd();
        }
      }
      if (struct.gcType != null) {
        if (struct.isSetGcType()) {
          oprot.writeFieldBegin(GC_TYPE_FIELD_DESC);
          oprot.writeI32(struct.gcType.getValue());
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TFJvmInfoTupleScheme extends org.apache.thrift.scheme.TupleScheme<TFJvmInfo> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TFJvmInfo 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.isSetVersion()) {
        optionals.set(0);
      }
      if (struct.isSetVmVersion()) {
        optionals.set(1);
      }
      if (struct.isSetGcType()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetVersion()) {
        oprot.writeI16(struct.version);
      }
      if (struct.isSetVmVersion()) {
        oprot.writeString(struct.vmVersion);
      }
      if (struct.isSetGcType()) {
        oprot.writeI32(struct.gcType.getValue());
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TFJvmInfo 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.version = iprot.readI16();
        struct.setVersionIsSet(true);
      }
      if (incoming.get(1)) {
        struct.vmVersion = iprot.readString();
        struct.setVmVersionIsSet(true);
      }
      if (incoming.get(2)) {
        struct.gcType = com.navercorp.pinpoint.thrift.dto.flink.TFJvmGcType.findByValue(iprot.readI32());
        struct.setGcTypeIsSet(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();
  }
}

