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

com.xiaomi.infra.galaxy.emr.thrift.ClusterDetailBill Maven / Gradle / Ivy

/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.xiaomi.infra.galaxy.emr.thrift;

import libthrift091.scheme.IScheme;
import libthrift091.scheme.SchemeFactory;
import libthrift091.scheme.StandardScheme;

import libthrift091.scheme.TupleScheme;
import libthrift091.protocol.TTupleProtocol;
import libthrift091.protocol.TProtocolException;
import libthrift091.EncodingUtils;
import libthrift091.TException;
import libthrift091.async.AsyncMethodCallback;
import libthrift091.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-4-18")
public class ClusterDetailBill implements libthrift091.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("ClusterDetailBill");

  private static final libthrift091.protocol.TField CLUSTER_ID_FIELD_DESC = new libthrift091.protocol.TField("clusterId", libthrift091.protocol.TType.STRING, (short)1);
  private static final libthrift091.protocol.TField COST_MAP_FIELD_DESC = new libthrift091.protocol.TField("costMap", libthrift091.protocol.TType.MAP, (short)2);
  private static final libthrift091.protocol.TField USE_TIME_FIELD_DESC = new libthrift091.protocol.TField("useTime", libthrift091.protocol.TType.MAP, (short)3);

  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new ClusterDetailBillStandardSchemeFactory());
    schemes.put(TupleScheme.class, new ClusterDetailBillTupleSchemeFactory());
  }

  public String clusterId; // required
  public Map costMap; // required
  public Map useTime; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements libthrift091.TFieldIdEnum {
    CLUSTER_ID((short)1, "clusterId"),
    COST_MAP((short)2, "costMap"),
    USE_TIME((short)3, "useTime");

    private static final Map byName = new HashMap();

    static {
      for (_Fields field : 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: // CLUSTER_ID
          return CLUSTER_ID;
        case 2: // COST_MAP
          return COST_MAP;
        case 3: // USE_TIME
          return USE_TIME;
        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 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(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  public static final Map<_Fields, libthrift091.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, libthrift091.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, libthrift091.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.CLUSTER_ID, new libthrift091.meta_data.FieldMetaData("clusterId", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)));
    tmpMap.put(_Fields.COST_MAP, new libthrift091.meta_data.FieldMetaData("costMap", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.MapMetaData(libthrift091.protocol.TType.MAP, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING), 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.I32))));
    tmpMap.put(_Fields.USE_TIME, new libthrift091.meta_data.FieldMetaData("useTime", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.MapMetaData(libthrift091.protocol.TType.MAP, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING), 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.I32))));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(ClusterDetailBill.class, metaDataMap);
  }

  public ClusterDetailBill() {
  }

  public ClusterDetailBill(
    String clusterId,
    Map costMap,
    Map useTime)
  {
    this();
    this.clusterId = clusterId;
    this.costMap = costMap;
    this.useTime = useTime;
  }

  /**
   * Performs a deep copy on other.
   */
  public ClusterDetailBill(ClusterDetailBill other) {
    if (other.isSetClusterId()) {
      this.clusterId = other.clusterId;
    }
    if (other.isSetCostMap()) {
      Map __this__costMap = new HashMap(other.costMap);
      this.costMap = __this__costMap;
    }
    if (other.isSetUseTime()) {
      Map __this__useTime = new HashMap(other.useTime);
      this.useTime = __this__useTime;
    }
  }

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

  @Override
  public void clear() {
    this.clusterId = null;
    this.costMap = null;
    this.useTime = null;
  }

  public String getClusterId() {
    return this.clusterId;
  }

  public ClusterDetailBill setClusterId(String clusterId) {
    this.clusterId = clusterId;
    return this;
  }

  public void unsetClusterId() {
    this.clusterId = null;
  }

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

  public void setClusterIdIsSet(boolean value) {
    if (!value) {
      this.clusterId = null;
    }
  }

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

  public void putToCostMap(String key, int val) {
    if (this.costMap == null) {
      this.costMap = new HashMap();
    }
    this.costMap.put(key, val);
  }

  public Map getCostMap() {
    return this.costMap;
  }

  public ClusterDetailBill setCostMap(Map costMap) {
    this.costMap = costMap;
    return this;
  }

  public void unsetCostMap() {
    this.costMap = null;
  }

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

  public void setCostMapIsSet(boolean value) {
    if (!value) {
      this.costMap = null;
    }
  }

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

  public void putToUseTime(String key, int val) {
    if (this.useTime == null) {
      this.useTime = new HashMap();
    }
    this.useTime.put(key, val);
  }

  public Map getUseTime() {
    return this.useTime;
  }

  public ClusterDetailBill setUseTime(Map useTime) {
    this.useTime = useTime;
    return this;
  }

  public void unsetUseTime() {
    this.useTime = null;
  }

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

  public void setUseTimeIsSet(boolean value) {
    if (!value) {
      this.useTime = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case CLUSTER_ID:
      if (value == null) {
        unsetClusterId();
      } else {
        setClusterId((String)value);
      }
      break;

    case COST_MAP:
      if (value == null) {
        unsetCostMap();
      } else {
        setCostMap((Map)value);
      }
      break;

    case USE_TIME:
      if (value == null) {
        unsetUseTime();
      } else {
        setUseTime((Map)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case CLUSTER_ID:
      return getClusterId();

    case COST_MAP:
      return getCostMap();

    case USE_TIME:
      return getUseTime();

    }
    throw new 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 IllegalArgumentException();
    }

    switch (field) {
    case CLUSTER_ID:
      return isSetClusterId();
    case COST_MAP:
      return isSetCostMap();
    case USE_TIME:
      return isSetUseTime();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(ClusterDetailBill that) {
    if (that == null)
      return false;

    boolean this_present_clusterId = true && this.isSetClusterId();
    boolean that_present_clusterId = true && that.isSetClusterId();
    if (this_present_clusterId || that_present_clusterId) {
      if (!(this_present_clusterId && that_present_clusterId))
        return false;
      if (!this.clusterId.equals(that.clusterId))
        return false;
    }

    boolean this_present_costMap = true && this.isSetCostMap();
    boolean that_present_costMap = true && that.isSetCostMap();
    if (this_present_costMap || that_present_costMap) {
      if (!(this_present_costMap && that_present_costMap))
        return false;
      if (!this.costMap.equals(that.costMap))
        return false;
    }

    boolean this_present_useTime = true && this.isSetUseTime();
    boolean that_present_useTime = true && that.isSetUseTime();
    if (this_present_useTime || that_present_useTime) {
      if (!(this_present_useTime && that_present_useTime))
        return false;
      if (!this.useTime.equals(that.useTime))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List list = new ArrayList();

    boolean present_clusterId = true && (isSetClusterId());
    list.add(present_clusterId);
    if (present_clusterId)
      list.add(clusterId);

    boolean present_costMap = true && (isSetCostMap());
    list.add(present_costMap);
    if (present_costMap)
      list.add(costMap);

    boolean present_useTime = true && (isSetUseTime());
    list.add(present_useTime);
    if (present_useTime)
      list.add(useTime);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetClusterId()).compareTo(other.isSetClusterId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetClusterId()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.clusterId, other.clusterId);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetCostMap()).compareTo(other.isSetCostMap());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCostMap()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.costMap, other.costMap);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetUseTime()).compareTo(other.isSetUseTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetUseTime()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.useTime, other.useTime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(libthrift091.protocol.TProtocol iprot) throws libthrift091.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("ClusterDetailBill(");
    boolean first = true;

    sb.append("clusterId:");
    if (this.clusterId == null) {
      sb.append("null");
    } else {
      sb.append(this.clusterId);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("costMap:");
    if (this.costMap == null) {
      sb.append("null");
    } else {
      sb.append(this.costMap);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("useTime:");
    if (this.useTime == null) {
      sb.append("null");
    } else {
      sb.append(this.useTime);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws libthrift091.TException {
    // check for required fields
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(out)));
    } catch (libthrift091.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      read(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(in)));
    } catch (libthrift091.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class ClusterDetailBillStandardSchemeFactory implements SchemeFactory {
    public ClusterDetailBillStandardScheme getScheme() {
      return new ClusterDetailBillStandardScheme();
    }
  }

  private static class ClusterDetailBillStandardScheme extends StandardScheme {

    public void read(libthrift091.protocol.TProtocol iprot, ClusterDetailBill struct) throws libthrift091.TException {
      libthrift091.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == libthrift091.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // CLUSTER_ID
            if (schemeField.type == libthrift091.protocol.TType.STRING) {
              struct.clusterId = iprot.readString();
              struct.setClusterIdIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // COST_MAP
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map8 = iprot.readMapBegin();
                struct.costMap = new HashMap(2*_map8.size);
                String _key9;
                int _val10;
                for (int _i11 = 0; _i11 < _map8.size; ++_i11)
                {
                  _key9 = iprot.readString();
                  _val10 = iprot.readI32();
                  struct.costMap.put(_key9, _val10);
                }
                iprot.readMapEnd();
              }
              struct.setCostMapIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // USE_TIME
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map12 = iprot.readMapBegin();
                struct.useTime = new HashMap(2*_map12.size);
                String _key13;
                int _val14;
                for (int _i15 = 0; _i15 < _map12.size; ++_i15)
                {
                  _key13 = iprot.readString();
                  _val14 = iprot.readI32();
                  struct.useTime.put(_key13, _val14);
                }
                iprot.readMapEnd();
              }
              struct.setUseTimeIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            libthrift091.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(libthrift091.protocol.TProtocol oprot, ClusterDetailBill struct) throws libthrift091.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.clusterId != null) {
        oprot.writeFieldBegin(CLUSTER_ID_FIELD_DESC);
        oprot.writeString(struct.clusterId);
        oprot.writeFieldEnd();
      }
      if (struct.costMap != null) {
        oprot.writeFieldBegin(COST_MAP_FIELD_DESC);
        {
          oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, struct.costMap.size()));
          for (Map.Entry _iter16 : struct.costMap.entrySet())
          {
            oprot.writeString(_iter16.getKey());
            oprot.writeI32(_iter16.getValue());
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.useTime != null) {
        oprot.writeFieldBegin(USE_TIME_FIELD_DESC);
        {
          oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, struct.useTime.size()));
          for (Map.Entry _iter17 : struct.useTime.entrySet())
          {
            oprot.writeString(_iter17.getKey());
            oprot.writeI32(_iter17.getValue());
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class ClusterDetailBillTupleSchemeFactory implements SchemeFactory {
    public ClusterDetailBillTupleScheme getScheme() {
      return new ClusterDetailBillTupleScheme();
    }
  }

  private static class ClusterDetailBillTupleScheme extends TupleScheme {

    @Override
    public void write(libthrift091.protocol.TProtocol prot, ClusterDetailBill struct) throws libthrift091.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetClusterId()) {
        optionals.set(0);
      }
      if (struct.isSetCostMap()) {
        optionals.set(1);
      }
      if (struct.isSetUseTime()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetClusterId()) {
        oprot.writeString(struct.clusterId);
      }
      if (struct.isSetCostMap()) {
        {
          oprot.writeI32(struct.costMap.size());
          for (Map.Entry _iter18 : struct.costMap.entrySet())
          {
            oprot.writeString(_iter18.getKey());
            oprot.writeI32(_iter18.getValue());
          }
        }
      }
      if (struct.isSetUseTime()) {
        {
          oprot.writeI32(struct.useTime.size());
          for (Map.Entry _iter19 : struct.useTime.entrySet())
          {
            oprot.writeString(_iter19.getKey());
            oprot.writeI32(_iter19.getValue());
          }
        }
      }
    }

    @Override
    public void read(libthrift091.protocol.TProtocol prot, ClusterDetailBill struct) throws libthrift091.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        struct.clusterId = iprot.readString();
        struct.setClusterIdIsSet(true);
      }
      if (incoming.get(1)) {
        {
          libthrift091.protocol.TMap _map20 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, iprot.readI32());
          struct.costMap = new HashMap(2*_map20.size);
          String _key21;
          int _val22;
          for (int _i23 = 0; _i23 < _map20.size; ++_i23)
          {
            _key21 = iprot.readString();
            _val22 = iprot.readI32();
            struct.costMap.put(_key21, _val22);
          }
        }
        struct.setCostMapIsSet(true);
      }
      if (incoming.get(2)) {
        {
          libthrift091.protocol.TMap _map24 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.I32, iprot.readI32());
          struct.useTime = new HashMap(2*_map24.size);
          String _key25;
          int _val26;
          for (int _i27 = 0; _i27 < _map24.size; ++_i27)
          {
            _key25 = iprot.readString();
            _val26 = iprot.readI32();
            struct.useTime.put(_key25, _val26);
          }
        }
        struct.setUseTimeIsSet(true);
      }
    }
  }

}