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

com.xiaomi.infra.galaxy.emq.thrift.PeekMessageResponse 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"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-9-13")
public class PeekMessageResponse implements libthrift091.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("PeekMessageResponse");

  private static final libthrift091.protocol.TField MESSAGE_ID_FIELD_DESC = new libthrift091.protocol.TField("messageID", libthrift091.protocol.TType.STRING, (short)1);
  private static final libthrift091.protocol.TField MESSAGE_BODY_FIELD_DESC = new libthrift091.protocol.TField("messageBody", libthrift091.protocol.TType.STRING, (short)2);
  private static final libthrift091.protocol.TField ATTRIBUTES_FIELD_DESC = new libthrift091.protocol.TField("attributes", libthrift091.protocol.TType.MAP, (short)3);
  private static final libthrift091.protocol.TField MESSAGE_ATTRIBUTES_FIELD_DESC = new libthrift091.protocol.TField("messageAttributes", libthrift091.protocol.TType.MAP, (short)4);
  private static final libthrift091.protocol.TField E_FIELD_DESC = new libthrift091.protocol.TField("e", libthrift091.protocol.TType.STRUCT, (short)5);

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

  /**
   * MessageID for the peeked message;
   * 
   */
  public String messageID; // required
  /**
   * Message body for the received message;
   * 
   */
  public String messageBody; // optional
  /**
   * Attributes of message, including:
   * - senderId
   * - priority
   * - messageLength
   * - md5OfBody
   * - sendTimestamp
   * - receiveTimestamp
   * - firstReceiveTimestamp
   * - receiveCount
   * 
   * If the message is received from a dead letter queue,
   * it has another four attributes:
   * - sourceQueueName
   * - sourceTag
   * - deadTimestamp
   * - originalMessageID
   * - originalReceiveCount
   * 
   * If the message has been set topic
   * - topic
   * 
   */
  public Map attributes; // optional
  /**
   * User-defined attributes attached to message
   * 
   */
  public Map messageAttributes; // optional
  /**
   * Peek message exception, when failed
   * 
   */
  public com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException e; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements libthrift091.TFieldIdEnum {
    /**
     * MessageID for the peeked message;
     * 
     */
    MESSAGE_ID((short)1, "messageID"),
    /**
     * Message body for the received message;
     * 
     */
    MESSAGE_BODY((short)2, "messageBody"),
    /**
     * Attributes of message, including:
     * - senderId
     * - priority
     * - messageLength
     * - md5OfBody
     * - sendTimestamp
     * - receiveTimestamp
     * - firstReceiveTimestamp
     * - receiveCount
     * 
     * If the message is received from a dead letter queue,
     * it has another four attributes:
     * - sourceQueueName
     * - sourceTag
     * - deadTimestamp
     * - originalMessageID
     * - originalReceiveCount
     * 
     * If the message has been set topic
     * - topic
     * 
     */
    ATTRIBUTES((short)3, "attributes"),
    /**
     * User-defined attributes attached to message
     * 
     */
    MESSAGE_ATTRIBUTES((short)4, "messageAttributes"),
    /**
     * Peek message exception, when failed
     * 
     */
    E((short)5, "e");

    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: // MESSAGE_ID
          return MESSAGE_ID;
        case 2: // MESSAGE_BODY
          return MESSAGE_BODY;
        case 3: // ATTRIBUTES
          return ATTRIBUTES;
        case 4: // MESSAGE_ATTRIBUTES
          return MESSAGE_ATTRIBUTES;
        case 5: // E
          return E;
        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
  private static final _Fields optionals[] = {_Fields.MESSAGE_BODY,_Fields.ATTRIBUTES,_Fields.MESSAGE_ATTRIBUTES,_Fields.E};
  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.MESSAGE_ID, new libthrift091.meta_data.FieldMetaData("messageID", libthrift091.TFieldRequirementType.REQUIRED, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)));
    tmpMap.put(_Fields.MESSAGE_BODY, new libthrift091.meta_data.FieldMetaData("messageBody", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING)));
    tmpMap.put(_Fields.ATTRIBUTES, new libthrift091.meta_data.FieldMetaData("attributes", libthrift091.TFieldRequirementType.OPTIONAL, 
        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.STRING))));
    tmpMap.put(_Fields.MESSAGE_ATTRIBUTES, new libthrift091.meta_data.FieldMetaData("messageAttributes", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.MapMetaData(libthrift091.protocol.TType.MAP, 
            new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRING), 
            new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, MessageAttribute.class))));
    tmpMap.put(_Fields.E, new libthrift091.meta_data.FieldMetaData("e", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.FieldValueMetaData(libthrift091.protocol.TType.STRUCT)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(PeekMessageResponse.class, metaDataMap);
  }

  public PeekMessageResponse() {
  }

  public PeekMessageResponse(
    String messageID)
  {
    this();
    this.messageID = messageID;
  }

  /**
   * Performs a deep copy on other.
   */
  public PeekMessageResponse(PeekMessageResponse other) {
    if (other.isSetMessageID()) {
      this.messageID = other.messageID;
    }
    if (other.isSetMessageBody()) {
      this.messageBody = other.messageBody;
    }
    if (other.isSetAttributes()) {
      Map __this__attributes = new HashMap(other.attributes);
      this.attributes = __this__attributes;
    }
    if (other.isSetMessageAttributes()) {
      Map __this__messageAttributes = new HashMap(other.messageAttributes.size());
      for (Map.Entry other_element : other.messageAttributes.entrySet()) {

        String other_element_key = other_element.getKey();
        MessageAttribute other_element_value = other_element.getValue();

        String __this__messageAttributes_copy_key = other_element_key;

        MessageAttribute __this__messageAttributes_copy_value = new MessageAttribute(other_element_value);

        __this__messageAttributes.put(__this__messageAttributes_copy_key, __this__messageAttributes_copy_value);
      }
      this.messageAttributes = __this__messageAttributes;
    }
    if (other.isSetE()) {
      this.e = new com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException(other.e);
    }
  }

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

  @Override
  public void clear() {
    this.messageID = null;
    this.messageBody = null;
    this.attributes = null;
    this.messageAttributes = null;
    this.e = null;
  }

  /**
   * MessageID for the peeked message;
   * 
   */
  public String getMessageID() {
    return this.messageID;
  }

  /**
   * MessageID for the peeked message;
   * 
   */
  public PeekMessageResponse setMessageID(String messageID) {
    this.messageID = messageID;
    return this;
  }

  public void unsetMessageID() {
    this.messageID = null;
  }

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

  public void setMessageIDIsSet(boolean value) {
    if (!value) {
      this.messageID = null;
    }
  }

  /**
   * Message body for the received message;
   * 
   */
  public String getMessageBody() {
    return this.messageBody;
  }

  /**
   * Message body for the received message;
   * 
   */
  public PeekMessageResponse setMessageBody(String messageBody) {
    this.messageBody = messageBody;
    return this;
  }

  public void unsetMessageBody() {
    this.messageBody = null;
  }

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

  public void setMessageBodyIsSet(boolean value) {
    if (!value) {
      this.messageBody = null;
    }
  }

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

  public void putToAttributes(String key, String val) {
    if (this.attributes == null) {
      this.attributes = new HashMap();
    }
    this.attributes.put(key, val);
  }

  /**
   * Attributes of message, including:
   * - senderId
   * - priority
   * - messageLength
   * - md5OfBody
   * - sendTimestamp
   * - receiveTimestamp
   * - firstReceiveTimestamp
   * - receiveCount
   * 
   * If the message is received from a dead letter queue,
   * it has another four attributes:
   * - sourceQueueName
   * - sourceTag
   * - deadTimestamp
   * - originalMessageID
   * - originalReceiveCount
   * 
   * If the message has been set topic
   * - topic
   * 
   */
  public Map getAttributes() {
    return this.attributes;
  }

  /**
   * Attributes of message, including:
   * - senderId
   * - priority
   * - messageLength
   * - md5OfBody
   * - sendTimestamp
   * - receiveTimestamp
   * - firstReceiveTimestamp
   * - receiveCount
   * 
   * If the message is received from a dead letter queue,
   * it has another four attributes:
   * - sourceQueueName
   * - sourceTag
   * - deadTimestamp
   * - originalMessageID
   * - originalReceiveCount
   * 
   * If the message has been set topic
   * - topic
   * 
   */
  public PeekMessageResponse setAttributes(Map attributes) {
    this.attributes = attributes;
    return this;
  }

  public void unsetAttributes() {
    this.attributes = null;
  }

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

  public void setAttributesIsSet(boolean value) {
    if (!value) {
      this.attributes = null;
    }
  }

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

  public void putToMessageAttributes(String key, MessageAttribute val) {
    if (this.messageAttributes == null) {
      this.messageAttributes = new HashMap();
    }
    this.messageAttributes.put(key, val);
  }

  /**
   * User-defined attributes attached to message
   * 
   */
  public Map getMessageAttributes() {
    return this.messageAttributes;
  }

  /**
   * User-defined attributes attached to message
   * 
   */
  public PeekMessageResponse setMessageAttributes(Map messageAttributes) {
    this.messageAttributes = messageAttributes;
    return this;
  }

  public void unsetMessageAttributes() {
    this.messageAttributes = null;
  }

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

  public void setMessageAttributesIsSet(boolean value) {
    if (!value) {
      this.messageAttributes = null;
    }
  }

  /**
   * Peek message exception, when failed
   * 
   */
  public com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException getE() {
    return this.e;
  }

  /**
   * Peek message exception, when failed
   * 
   */
  public PeekMessageResponse setE(com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException e) {
    this.e = e;
    return this;
  }

  public void unsetE() {
    this.e = null;
  }

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

  public void setEIsSet(boolean value) {
    if (!value) {
      this.e = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case MESSAGE_ID:
      if (value == null) {
        unsetMessageID();
      } else {
        setMessageID((String)value);
      }
      break;

    case MESSAGE_BODY:
      if (value == null) {
        unsetMessageBody();
      } else {
        setMessageBody((String)value);
      }
      break;

    case ATTRIBUTES:
      if (value == null) {
        unsetAttributes();
      } else {
        setAttributes((Map)value);
      }
      break;

    case MESSAGE_ATTRIBUTES:
      if (value == null) {
        unsetMessageAttributes();
      } else {
        setMessageAttributes((Map)value);
      }
      break;

    case E:
      if (value == null) {
        unsetE();
      } else {
        setE((com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case MESSAGE_ID:
      return getMessageID();

    case MESSAGE_BODY:
      return getMessageBody();

    case ATTRIBUTES:
      return getAttributes();

    case MESSAGE_ATTRIBUTES:
      return getMessageAttributes();

    case E:
      return getE();

    }
    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 MESSAGE_ID:
      return isSetMessageID();
    case MESSAGE_BODY:
      return isSetMessageBody();
    case ATTRIBUTES:
      return isSetAttributes();
    case MESSAGE_ATTRIBUTES:
      return isSetMessageAttributes();
    case E:
      return isSetE();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_messageID = true && this.isSetMessageID();
    boolean that_present_messageID = true && that.isSetMessageID();
    if (this_present_messageID || that_present_messageID) {
      if (!(this_present_messageID && that_present_messageID))
        return false;
      if (!this.messageID.equals(that.messageID))
        return false;
    }

    boolean this_present_messageBody = true && this.isSetMessageBody();
    boolean that_present_messageBody = true && that.isSetMessageBody();
    if (this_present_messageBody || that_present_messageBody) {
      if (!(this_present_messageBody && that_present_messageBody))
        return false;
      if (!this.messageBody.equals(that.messageBody))
        return false;
    }

    boolean this_present_attributes = true && this.isSetAttributes();
    boolean that_present_attributes = true && that.isSetAttributes();
    if (this_present_attributes || that_present_attributes) {
      if (!(this_present_attributes && that_present_attributes))
        return false;
      if (!this.attributes.equals(that.attributes))
        return false;
    }

    boolean this_present_messageAttributes = true && this.isSetMessageAttributes();
    boolean that_present_messageAttributes = true && that.isSetMessageAttributes();
    if (this_present_messageAttributes || that_present_messageAttributes) {
      if (!(this_present_messageAttributes && that_present_messageAttributes))
        return false;
      if (!this.messageAttributes.equals(that.messageAttributes))
        return false;
    }

    boolean this_present_e = true && this.isSetE();
    boolean that_present_e = true && that.isSetE();
    if (this_present_e || that_present_e) {
      if (!(this_present_e && that_present_e))
        return false;
      if (!this.e.equals(that.e))
        return false;
    }

    return true;
  }

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

    boolean present_messageID = true && (isSetMessageID());
    list.add(present_messageID);
    if (present_messageID)
      list.add(messageID);

    boolean present_messageBody = true && (isSetMessageBody());
    list.add(present_messageBody);
    if (present_messageBody)
      list.add(messageBody);

    boolean present_attributes = true && (isSetAttributes());
    list.add(present_attributes);
    if (present_attributes)
      list.add(attributes);

    boolean present_messageAttributes = true && (isSetMessageAttributes());
    list.add(present_messageAttributes);
    if (present_messageAttributes)
      list.add(messageAttributes);

    boolean present_e = true && (isSetE());
    list.add(present_e);
    if (present_e)
      list.add(e);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetMessageID()).compareTo(other.isSetMessageID());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMessageID()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.messageID, other.messageID);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMessageBody()).compareTo(other.isSetMessageBody());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMessageBody()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.messageBody, other.messageBody);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(other.isSetAttributes());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAttributes()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.attributes, other.attributes);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetMessageAttributes()).compareTo(other.isSetMessageAttributes());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMessageAttributes()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.messageAttributes, other.messageAttributes);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetE()).compareTo(other.isSetE());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetE()) {
      lastComparison = libthrift091.TBaseHelper.compareTo(this.e, other.e);
      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("PeekMessageResponse(");
    boolean first = true;

    sb.append("messageID:");
    if (this.messageID == null) {
      sb.append("null");
    } else {
      sb.append(this.messageID);
    }
    first = false;
    if (isSetMessageBody()) {
      if (!first) sb.append(", ");
      sb.append("messageBody:");
      if (this.messageBody == null) {
        sb.append("null");
      } else {
        sb.append(this.messageBody);
      }
      first = false;
    }
    if (isSetAttributes()) {
      if (!first) sb.append(", ");
      sb.append("attributes:");
      if (this.attributes == null) {
        sb.append("null");
      } else {
        sb.append(this.attributes);
      }
      first = false;
    }
    if (isSetMessageAttributes()) {
      if (!first) sb.append(", ");
      sb.append("messageAttributes:");
      if (this.messageAttributes == null) {
        sb.append("null");
      } else {
        sb.append(this.messageAttributes);
      }
      first = false;
    }
    if (isSetE()) {
      if (!first) sb.append(", ");
      sb.append("e:");
      if (this.e == null) {
        sb.append("null");
      } else {
        sb.append(this.e);
      }
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws libthrift091.TException {
    // check for required fields
    if (messageID == null) {
      throw new libthrift091.protocol.TProtocolException("Required field 'messageID' was not present! Struct: " + toString());
    }
    // 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 PeekMessageResponseStandardSchemeFactory implements SchemeFactory {
    public PeekMessageResponseStandardScheme getScheme() {
      return new PeekMessageResponseStandardScheme();
    }
  }

  private static class PeekMessageResponseStandardScheme extends StandardScheme {

    public void read(libthrift091.protocol.TProtocol iprot, PeekMessageResponse 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: // MESSAGE_ID
            if (schemeField.type == libthrift091.protocol.TType.STRING) {
              struct.messageID = iprot.readString();
              struct.setMessageIDIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // MESSAGE_BODY
            if (schemeField.type == libthrift091.protocol.TType.STRING) {
              struct.messageBody = iprot.readString();
              struct.setMessageBodyIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // ATTRIBUTES
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map136 = iprot.readMapBegin();
                struct.attributes = new HashMap(2*_map136.size);
                String _key137;
                String _val138;
                for (int _i139 = 0; _i139 < _map136.size; ++_i139)
                {
                  _key137 = iprot.readString();
                  _val138 = iprot.readString();
                  struct.attributes.put(_key137, _val138);
                }
                iprot.readMapEnd();
              }
              struct.setAttributesIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // MESSAGE_ATTRIBUTES
            if (schemeField.type == libthrift091.protocol.TType.MAP) {
              {
                libthrift091.protocol.TMap _map140 = iprot.readMapBegin();
                struct.messageAttributes = new HashMap(2*_map140.size);
                String _key141;
                MessageAttribute _val142;
                for (int _i143 = 0; _i143 < _map140.size; ++_i143)
                {
                  _key141 = iprot.readString();
                  _val142 = new MessageAttribute();
                  _val142.read(iprot);
                  struct.messageAttributes.put(_key141, _val142);
                }
                iprot.readMapEnd();
              }
              struct.setMessageAttributesIsSet(true);
            } else { 
              libthrift091.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // E
            if (schemeField.type == libthrift091.protocol.TType.STRUCT) {
              struct.e = new com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException();
              struct.e.read(iprot);
              struct.setEIsSet(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, PeekMessageResponse struct) throws libthrift091.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.messageID != null) {
        oprot.writeFieldBegin(MESSAGE_ID_FIELD_DESC);
        oprot.writeString(struct.messageID);
        oprot.writeFieldEnd();
      }
      if (struct.messageBody != null) {
        if (struct.isSetMessageBody()) {
          oprot.writeFieldBegin(MESSAGE_BODY_FIELD_DESC);
          oprot.writeString(struct.messageBody);
          oprot.writeFieldEnd();
        }
      }
      if (struct.attributes != null) {
        if (struct.isSetAttributes()) {
          oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
          {
            oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRING, struct.attributes.size()));
            for (Map.Entry _iter144 : struct.attributes.entrySet())
            {
              oprot.writeString(_iter144.getKey());
              oprot.writeString(_iter144.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.messageAttributes != null) {
        if (struct.isSetMessageAttributes()) {
          oprot.writeFieldBegin(MESSAGE_ATTRIBUTES_FIELD_DESC);
          {
            oprot.writeMapBegin(new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRUCT, struct.messageAttributes.size()));
            for (Map.Entry _iter145 : struct.messageAttributes.entrySet())
            {
              oprot.writeString(_iter145.getKey());
              _iter145.getValue().write(oprot);
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.e != null) {
        if (struct.isSetE()) {
          oprot.writeFieldBegin(E_FIELD_DESC);
          struct.e.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class PeekMessageResponseTupleSchemeFactory implements SchemeFactory {
    public PeekMessageResponseTupleScheme getScheme() {
      return new PeekMessageResponseTupleScheme();
    }
  }

  private static class PeekMessageResponseTupleScheme extends TupleScheme {

    @Override
    public void write(libthrift091.protocol.TProtocol prot, PeekMessageResponse struct) throws libthrift091.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      oprot.writeString(struct.messageID);
      BitSet optionals = new BitSet();
      if (struct.isSetMessageBody()) {
        optionals.set(0);
      }
      if (struct.isSetAttributes()) {
        optionals.set(1);
      }
      if (struct.isSetMessageAttributes()) {
        optionals.set(2);
      }
      if (struct.isSetE()) {
        optionals.set(3);
      }
      oprot.writeBitSet(optionals, 4);
      if (struct.isSetMessageBody()) {
        oprot.writeString(struct.messageBody);
      }
      if (struct.isSetAttributes()) {
        {
          oprot.writeI32(struct.attributes.size());
          for (Map.Entry _iter146 : struct.attributes.entrySet())
          {
            oprot.writeString(_iter146.getKey());
            oprot.writeString(_iter146.getValue());
          }
        }
      }
      if (struct.isSetMessageAttributes()) {
        {
          oprot.writeI32(struct.messageAttributes.size());
          for (Map.Entry _iter147 : struct.messageAttributes.entrySet())
          {
            oprot.writeString(_iter147.getKey());
            _iter147.getValue().write(oprot);
          }
        }
      }
      if (struct.isSetE()) {
        struct.e.write(oprot);
      }
    }

    @Override
    public void read(libthrift091.protocol.TProtocol prot, PeekMessageResponse struct) throws libthrift091.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      struct.messageID = iprot.readString();
      struct.setMessageIDIsSet(true);
      BitSet incoming = iprot.readBitSet(4);
      if (incoming.get(0)) {
        struct.messageBody = iprot.readString();
        struct.setMessageBodyIsSet(true);
      }
      if (incoming.get(1)) {
        {
          libthrift091.protocol.TMap _map148 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRING, iprot.readI32());
          struct.attributes = new HashMap(2*_map148.size);
          String _key149;
          String _val150;
          for (int _i151 = 0; _i151 < _map148.size; ++_i151)
          {
            _key149 = iprot.readString();
            _val150 = iprot.readString();
            struct.attributes.put(_key149, _val150);
          }
        }
        struct.setAttributesIsSet(true);
      }
      if (incoming.get(2)) {
        {
          libthrift091.protocol.TMap _map152 = new libthrift091.protocol.TMap(libthrift091.protocol.TType.STRING, libthrift091.protocol.TType.STRUCT, iprot.readI32());
          struct.messageAttributes = new HashMap(2*_map152.size);
          String _key153;
          MessageAttribute _val154;
          for (int _i155 = 0; _i155 < _map152.size; ++_i155)
          {
            _key153 = iprot.readString();
            _val154 = new MessageAttribute();
            _val154.read(iprot);
            struct.messageAttributes.put(_key153, _val154);
          }
        }
        struct.setMessageAttributesIsSet(true);
      }
      if (incoming.get(3)) {
        struct.e = new com.xiaomi.infra.galaxy.emq.thrift.GalaxyEmqServiceException();
        struct.e.read(iprot);
        struct.setEIsSet(true);
      }
    }
  }

}