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

com.xiaomi.infra.galaxy.emq.thrift.PeekMessageArg Maven / Gradle / Ivy

The newest version!
/**
 * 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.emq.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"})
public class PeekMessageArg extends libthrift091.TUnion {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("PeekMessageArg");
  private static final libthrift091.protocol.TField RECEIPT_HANDLE_FIELD_DESC = new libthrift091.protocol.TField("receiptHandle", libthrift091.protocol.TType.STRING, (short)1);
  private static final libthrift091.protocol.TField RECEIPT_HANDLE_LIST_FIELD_DESC = new libthrift091.protocol.TField("receiptHandleList", libthrift091.protocol.TType.LIST, (short)2);
  private static final libthrift091.protocol.TField PARTITION_TIME_INTERVAL_AND_MAX_NUM_FIELD_DESC = new libthrift091.protocol.TField("partitionTimeIntervalAndMaxNum", libthrift091.protocol.TType.STRUCT, (short)3);

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements libthrift091.TFieldIdEnum {
    /**
     * receipt handle of message to peek;
     * 
     */
    RECEIPT_HANDLE((short)1, "receiptHandle"),
    /**
     * List of PeekMessageRequest;
     * 
     */
    RECEIPT_HANDLE_LIST((short)2, "receiptHandleList"),
    /**
     * Using timeInterval to peek messages
     * 
     */
    PARTITION_TIME_INTERVAL_AND_MAX_NUM((short)3, "partitionTimeIntervalAndMaxNum");

    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: // RECEIPT_HANDLE
          return RECEIPT_HANDLE;
        case 2: // RECEIPT_HANDLE_LIST
          return RECEIPT_HANDLE_LIST;
        case 3: // PARTITION_TIME_INTERVAL_AND_MAX_NUM
          return PARTITION_TIME_INTERVAL_AND_MAX_NUM;
        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;
    }
  }

  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.RECEIPT_HANDLE, new libthrift091.meta_data.FieldMetaData("receiptHandle", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)));
    tmpMap.put(_Fields.RECEIPT_HANDLE_LIST, new libthrift091.meta_data.FieldMetaData("receiptHandleList", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.ListMetaData(libthrift091.protocol.TType.LIST, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING))));
    tmpMap.put(_Fields.PARTITION_TIME_INTERVAL_AND_MAX_NUM, new libthrift091.meta_data.FieldMetaData("partitionTimeIntervalAndMaxNum", libthrift091.TFieldRequirementType.DEFAULT, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, PartitionTimeIntervalAndMaxNum.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(PeekMessageArg.class, metaDataMap);
  }

  public PeekMessageArg() {
    super();
  }

  public PeekMessageArg(_Fields setField, Object value) {
    super(setField, value);
  }

  public PeekMessageArg(PeekMessageArg other) {
    super(other);
  }
  public PeekMessageArg deepCopy() {
    return new PeekMessageArg(this);
  }

  public static PeekMessageArg receiptHandle(String value) {
    PeekMessageArg x = new PeekMessageArg();
    x.setReceiptHandle(value);
    return x;
  }

  public static PeekMessageArg receiptHandleList(List value) {
    PeekMessageArg x = new PeekMessageArg();
    x.setReceiptHandleList(value);
    return x;
  }

  public static PeekMessageArg partitionTimeIntervalAndMaxNum(PartitionTimeIntervalAndMaxNum value) {
    PeekMessageArg x = new PeekMessageArg();
    x.setPartitionTimeIntervalAndMaxNum(value);
    return x;
  }


  @Override
  protected void checkType(_Fields setField, Object value) throws ClassCastException {
    switch (setField) {
      case RECEIPT_HANDLE:
        if (value instanceof String) {
          break;
        }
        throw new ClassCastException("Was expecting value of type String for field 'receiptHandle', but got " + value.getClass().getSimpleName());
      case RECEIPT_HANDLE_LIST:
        if (value instanceof List) {
          break;
        }
        throw new ClassCastException("Was expecting value of type List for field 'receiptHandleList', but got " + value.getClass().getSimpleName());
      case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
        if (value instanceof PartitionTimeIntervalAndMaxNum) {
          break;
        }
        throw new ClassCastException("Was expecting value of type PartitionTimeIntervalAndMaxNum for field 'partitionTimeIntervalAndMaxNum', but got " + value.getClass().getSimpleName());
      default:
        throw new IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected Object standardSchemeReadValue(libthrift091.protocol.TProtocol iprot, libthrift091.protocol.TField field) throws libthrift091.TException {
    _Fields setField = _Fields.findByThriftId(field.id);
    if (setField != null) {
      switch (setField) {
        case RECEIPT_HANDLE:
          if (field.type == RECEIPT_HANDLE_FIELD_DESC.type) {
            String receiptHandle;
            receiptHandle = iprot.readString();
            return receiptHandle;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case RECEIPT_HANDLE_LIST:
          if (field.type == RECEIPT_HANDLE_LIST_FIELD_DESC.type) {
            List receiptHandleList;
            {
              libthrift091.protocol.TList _list180 = iprot.readListBegin();
              receiptHandleList = new ArrayList(_list180.size);
              String _elem181;
              for (int _i182 = 0; _i182 < _list180.size; ++_i182)
              {
                _elem181 = iprot.readString();
                receiptHandleList.add(_elem181);
              }
              iprot.readListEnd();
            }
            return receiptHandleList;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
          if (field.type == PARTITION_TIME_INTERVAL_AND_MAX_NUM_FIELD_DESC.type) {
            PartitionTimeIntervalAndMaxNum partitionTimeIntervalAndMaxNum;
            partitionTimeIntervalAndMaxNum = new PartitionTimeIntervalAndMaxNum();
            partitionTimeIntervalAndMaxNum.read(iprot);
            return partitionTimeIntervalAndMaxNum;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        default:
          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
      return null;
    }
  }

  @Override
  protected void standardSchemeWriteValue(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    switch (setField_) {
      case RECEIPT_HANDLE:
        String receiptHandle = (String)value_;
        oprot.writeString(receiptHandle);
        return;
      case RECEIPT_HANDLE_LIST:
        List receiptHandleList = (List)value_;
        {
          oprot.writeListBegin(new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, receiptHandleList.size()));
          for (String _iter183 : receiptHandleList)
          {
            oprot.writeString(_iter183);
          }
          oprot.writeListEnd();
        }
        return;
      case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
        PartitionTimeIntervalAndMaxNum partitionTimeIntervalAndMaxNum = (PartitionTimeIntervalAndMaxNum)value_;
        partitionTimeIntervalAndMaxNum.write(oprot);
        return;
      default:
        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected Object tupleSchemeReadValue(libthrift091.protocol.TProtocol iprot, short fieldID) throws libthrift091.TException {
    _Fields setField = _Fields.findByThriftId(fieldID);
    if (setField != null) {
      switch (setField) {
        case RECEIPT_HANDLE:
          String receiptHandle;
          receiptHandle = iprot.readString();
          return receiptHandle;
        case RECEIPT_HANDLE_LIST:
          List receiptHandleList;
          {
            libthrift091.protocol.TList _list184 = iprot.readListBegin();
            receiptHandleList = new ArrayList(_list184.size);
            String _elem185;
            for (int _i186 = 0; _i186 < _list184.size; ++_i186)
            {
              _elem185 = iprot.readString();
              receiptHandleList.add(_elem185);
            }
            iprot.readListEnd();
          }
          return receiptHandleList;
        case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
          PartitionTimeIntervalAndMaxNum partitionTimeIntervalAndMaxNum;
          partitionTimeIntervalAndMaxNum = new PartitionTimeIntervalAndMaxNum();
          partitionTimeIntervalAndMaxNum.read(iprot);
          return partitionTimeIntervalAndMaxNum;
        default:
          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      throw new TProtocolException("Couldn't find a field with field id " + fieldID);
    }
  }

  @Override
  protected void tupleSchemeWriteValue(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    switch (setField_) {
      case RECEIPT_HANDLE:
        String receiptHandle = (String)value_;
        oprot.writeString(receiptHandle);
        return;
      case RECEIPT_HANDLE_LIST:
        List receiptHandleList = (List)value_;
        {
          oprot.writeListBegin(new libthrift091.protocol.TList(libthrift091.protocol.TType.STRING, receiptHandleList.size()));
          for (String _iter187 : receiptHandleList)
          {
            oprot.writeString(_iter187);
          }
          oprot.writeListEnd();
        }
        return;
      case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
        PartitionTimeIntervalAndMaxNum partitionTimeIntervalAndMaxNum = (PartitionTimeIntervalAndMaxNum)value_;
        partitionTimeIntervalAndMaxNum.write(oprot);
        return;
      default:
        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected libthrift091.protocol.TField getFieldDesc(_Fields setField) {
    switch (setField) {
      case RECEIPT_HANDLE:
        return RECEIPT_HANDLE_FIELD_DESC;
      case RECEIPT_HANDLE_LIST:
        return RECEIPT_HANDLE_LIST_FIELD_DESC;
      case PARTITION_TIME_INTERVAL_AND_MAX_NUM:
        return PARTITION_TIME_INTERVAL_AND_MAX_NUM_FIELD_DESC;
      default:
        throw new IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected libthrift091.protocol.TStruct getStructDesc() {
    return STRUCT_DESC;
  }

  @Override
  protected _Fields enumForId(short id) {
    return _Fields.findByThriftIdOrThrow(id);
  }

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


  /**
   * receipt handle of message to peek;
   * 
   */
  public String getReceiptHandle() {
    if (getSetField() == _Fields.RECEIPT_HANDLE) {
      return (String)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'receiptHandle' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * receipt handle of message to peek;
   * 
   */
  public void setReceiptHandle(String value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.RECEIPT_HANDLE;
    value_ = value;
  }

  /**
   * List of PeekMessageRequest;
   * 
   */
  public List getReceiptHandleList() {
    if (getSetField() == _Fields.RECEIPT_HANDLE_LIST) {
      return (List)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'receiptHandleList' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * List of PeekMessageRequest;
   * 
   */
  public void setReceiptHandleList(List value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.RECEIPT_HANDLE_LIST;
    value_ = value;
  }

  /**
   * Using timeInterval to peek messages
   * 
   */
  public PartitionTimeIntervalAndMaxNum getPartitionTimeIntervalAndMaxNum() {
    if (getSetField() == _Fields.PARTITION_TIME_INTERVAL_AND_MAX_NUM) {
      return (PartitionTimeIntervalAndMaxNum)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'partitionTimeIntervalAndMaxNum' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * Using timeInterval to peek messages
   * 
   */
  public void setPartitionTimeIntervalAndMaxNum(PartitionTimeIntervalAndMaxNum value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.PARTITION_TIME_INTERVAL_AND_MAX_NUM;
    value_ = value;
  }

  public boolean isSetReceiptHandle() {
    return setField_ == _Fields.RECEIPT_HANDLE;
  }


  public boolean isSetReceiptHandleList() {
    return setField_ == _Fields.RECEIPT_HANDLE_LIST;
  }


  public boolean isSetPartitionTimeIntervalAndMaxNum() {
    return setField_ == _Fields.PARTITION_TIME_INTERVAL_AND_MAX_NUM;
  }


  public boolean equals(Object other) {
    if (other instanceof PeekMessageArg) {
      return equals((PeekMessageArg)other);
    } else {
      return false;
    }
  }

  public boolean equals(PeekMessageArg other) {
    return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
  }

  @Override
  public int compareTo(PeekMessageArg other) {
    int lastComparison = libthrift091.TBaseHelper.compareTo(getSetField(), other.getSetField());
    if (lastComparison == 0) {
      return libthrift091.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
    }
    return lastComparison;
  }


  @Override
  public int hashCode() {
    List list = new ArrayList();
    list.add(this.getClass().getName());
    libthrift091.TFieldIdEnum setField = getSetField();
    if (setField != null) {
      list.add(setField.getThriftFieldId());
      Object value = getFieldValue();
      if (value instanceof libthrift091.TEnum) {
        list.add(((libthrift091.TEnum)getFieldValue()).getValue());
      } else {
        list.add(value);
      }
    }
    return list.hashCode();
  }
  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);
    }
  }


}