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

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

  private static final org.apache.thrift.protocol.TField SERVICE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceName", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField SERVICE_LIBS_FIELD_DESC = new org.apache.thrift.protocol.TField("serviceLibs", org.apache.thrift.protocol.TType.LIST, (short)2);

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

  private java.lang.String serviceName; // optional
  private java.util.List<java.lang.String> serviceLibs; // 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 {
    SERVICE_NAME((short)1, "serviceName"),
    SERVICE_LIBS((short)2, "serviceLibs");

    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: // SERVICE_NAME
          return SERVICE_NAME;
        case 2: // SERVICE_LIBS
          return SERVICE_LIBS;
        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 _Fields optionals[] = {_Fields.SERVICE_NAME,_Fields.SERVICE_LIBS};
  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.SERVICE_NAME, new org.apache.thrift.meta_data.FieldMetaData("serviceName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.SERVICE_LIBS, new org.apache.thrift.meta_data.FieldMetaData("serviceLibs", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            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(TServiceInfo.class, metaDataMap);
  }

  public TServiceInfo() {
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public TServiceInfo(TServiceInfo other) {
    if (other.isSetServiceName()) {
      this.serviceName = other.serviceName;
    }
    if (other.isSetServiceLibs()) {
      java.util.List<java.lang.String> __this__serviceLibs = new java.util.ArrayList<java.lang.String>(other.serviceLibs);
      this.serviceLibs = __this__serviceLibs;
    }
  }

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

  @Override
  public void clear() {
    this.serviceName = null;
    this.serviceLibs = null;
  }

  public java.lang.String getServiceName() {
    return this.serviceName;
  }

  public void setServiceName(java.lang.String serviceName) {
    this.serviceName = serviceName;
  }

  public void unsetServiceName() {
    this.serviceName = null;
  }

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

  public void setServiceNameIsSet(boolean value) {
    if (!value) {
      this.serviceName = null;
    }
  }

  public int getServiceLibsSize() {
    return (this.serviceLibs == null) ? 0 : this.serviceLibs.size();
  }

  public java.util.Iterator<java.lang.String> getServiceLibsIterator() {
    return (this.serviceLibs == null) ? null : this.serviceLibs.iterator();
  }

  public void addToServiceLibs(java.lang.String elem) {
    if (this.serviceLibs == null) {
      this.serviceLibs = new java.util.ArrayList<java.lang.String>();
    }
    this.serviceLibs.add(elem);
  }

  public java.util.List<java.lang.String> getServiceLibs() {
    return this.serviceLibs;
  }

  public void setServiceLibs(java.util.List<java.lang.String> serviceLibs) {
    this.serviceLibs = serviceLibs;
  }

  public void unsetServiceLibs() {
    this.serviceLibs = null;
  }

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

  public void setServiceLibsIsSet(boolean value) {
    if (!value) {
      this.serviceLibs = null;
    }
  }

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

    case SERVICE_LIBS:
      if (value == null) {
        unsetServiceLibs();
      } else {
        setServiceLibs((java.util.List<java.lang.String>)value);
      }
      break;

    }
  }

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

    case SERVICE_LIBS:
      return getServiceLibs();

    }
    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 SERVICE_NAME:
      return isSetServiceName();
    case SERVICE_LIBS:
      return isSetServiceLibs();
    }
    throw new java.lang.IllegalStateException();
  }

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

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

    boolean this_present_serviceName = true && this.isSetServiceName();
    boolean that_present_serviceName = true && that.isSetServiceName();
    if (this_present_serviceName || that_present_serviceName) {
      if (!(this_present_serviceName && that_present_serviceName))
        return false;
      if (!this.serviceName.equals(that.serviceName))
        return false;
    }

    boolean this_present_serviceLibs = true && this.isSetServiceLibs();
    boolean that_present_serviceLibs = true && that.isSetServiceLibs();
    if (this_present_serviceLibs || that_present_serviceLibs) {
      if (!(this_present_serviceLibs && that_present_serviceLibs))
        return false;
      if (!this.serviceLibs.equals(that.serviceLibs))
        return false;
    }

    return true;
  }

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

    hashCode = hashCode * 8191 + ((isSetServiceName()) ? 131071 : 524287);
    if (isSetServiceName())
      hashCode = hashCode * 8191 + serviceName.hashCode();

    hashCode = hashCode * 8191 + ((isSetServiceLibs()) ? 131071 : 524287);
    if (isSetServiceLibs())
      hashCode = hashCode * 8191 + serviceLibs.hashCode();

    return hashCode;
  }

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

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetServiceName()).compareTo(other.isSetServiceName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetServiceName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceName, other.serviceName);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetServiceLibs()).compareTo(other.isSetServiceLibs());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetServiceLibs()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serviceLibs, other.serviceLibs);
      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("TServiceInfo(");
    boolean first = true;

    if (isSetServiceName()) {
      sb.append("serviceName:");
      if (this.serviceName == null) {
        sb.append("null");
      } else {
        sb.append(this.serviceName);
      }
      first = false;
    }
    if (isSetServiceLibs()) {
      if (!first) sb.append(", ");
      sb.append("serviceLibs:");
      if (this.serviceLibs == null) {
        sb.append("null");
      } else {
        sb.append(this.serviceLibs);
      }
      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 {
      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 TServiceInfoStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public TServiceInfoStandardScheme getScheme() {
      return new TServiceInfoStandardScheme();
    }
  }

  private static class TServiceInfoStandardScheme extends org.apache.thrift.scheme.StandardScheme<TServiceInfo> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, TServiceInfo 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: // SERVICE_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.serviceName = iprot.readString();
              struct.setServiceNameIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // SERVICE_LIBS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
                struct.serviceLibs = new java.util.ArrayList<java.lang.String>(_list0.size);
                java.lang.String _elem1;
                for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                {
                  _elem1 = iprot.readString();
                  struct.serviceLibs.add(_elem1);
                }
                iprot.readListEnd();
              }
              struct.setServiceLibsIsSet(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, TServiceInfo struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.serviceName != null) {
        if (struct.isSetServiceName()) {
          oprot.writeFieldBegin(SERVICE_NAME_FIELD_DESC);
          oprot.writeString(struct.serviceName);
          oprot.writeFieldEnd();
        }
      }
      if (struct.serviceLibs != null) {
        if (struct.isSetServiceLibs()) {
          oprot.writeFieldBegin(SERVICE_LIBS_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.serviceLibs.size()));
            for (java.lang.String _iter3 : struct.serviceLibs)
            {
              oprot.writeString(_iter3);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

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

  private static class TServiceInfoTupleScheme extends org.apache.thrift.scheme.TupleScheme<TServiceInfo> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, TServiceInfo 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.isSetServiceName()) {
        optionals.set(0);
      }
      if (struct.isSetServiceLibs()) {
        optionals.set(1);
      }
      oprot.writeBitSet(optionals, 2);
      if (struct.isSetServiceName()) {
        oprot.writeString(struct.serviceName);
      }
      if (struct.isSetServiceLibs()) {
        {
          oprot.writeI32(struct.serviceLibs.size());
          for (java.lang.String _iter4 : struct.serviceLibs)
          {
            oprot.writeString(_iter4);
          }
        }
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, TServiceInfo struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(2);
      if (incoming.get(0)) {
        struct.serviceName = iprot.readString();
        struct.setServiceNameIsSet(true);
      }
      if (incoming.get(1)) {
        {
          org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
          struct.serviceLibs = new java.util.ArrayList<java.lang.String>(_list5.size);
          java.lang.String _elem6;
          for (int _i7 = 0; _i7 < _list5.size; ++_i7)
          {
            _elem6 = iprot.readString();
            struct.serviceLibs.add(_elem6);
          }
        }
        struct.setServiceLibsIsSet(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();
  }
}

