// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.proto;

import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;

public final class ChatContentInfoOuterClass {
  /**
   * Protobuf type {@code ChatContentInfo}
   */
  public static final class ChatContentInfo extends ProtoMessage<ChatContentInfo> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional .MsgType msg_type = 1;</code>
     */
    private int msgType;

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     */
    private final ChatMsgInfoOuterClass.ChatMsgInfo chatMsg = ChatMsgInfoOuterClass.ChatMsgInfo.newInstance();

    private ChatContentInfo() {
    }

    /**
     * @return a new empty instance of {@code ChatContentInfo}
     */
    public static ChatContentInfo newInstance() {
      return new ChatContentInfo();
    }

    /**
     * <code>optional .MsgType msg_type = 1;</code>
     * @return whether the msgType field is set
     */
    public boolean hasMsgType() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .MsgType msg_type = 1;</code>
     * @return this
     */
    public ChatContentInfo clearMsgType() {
      bitField0_ &= ~0x00000001;
      msgType = 0;
      return this;
    }

    /**
     * <code>optional .MsgType msg_type = 1;</code>
     * @return the msgType
     */
    public MsgTypeOuterClass.MsgType getMsgType() {
      return MsgTypeOuterClass.MsgType.forNumber(msgType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link ChatContentInfo#getMsgType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getMsgTypeValue() {
      return msgType;
    }

    /**
     * Sets the value of the internal enum store. This does not
     * do any validity checks, so be sure to use appropriate value
     * constants from {@link MsgTypeOuterClass.MsgType}. Setting an invalid value
     * can cause {@link ChatContentInfo#getMsgType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public ChatContentInfo setMsgTypeValue(final int value) {
      bitField0_ |= 0x00000001;
      msgType = value;
      return this;
    }

    /**
     * <code>optional .MsgType msg_type = 1;</code>
     * @param value the msgType to set
     * @return this
     */
    public ChatContentInfo setMsgType(final MsgTypeOuterClass.MsgType value) {
      bitField0_ |= 0x00000001;
      msgType = value.getNumber();
      return this;
    }

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     * @return whether the chatMsg field is set
     */
    public boolean hasChatMsg() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     * @return this
     */
    public ChatContentInfo clearChatMsg() {
      bitField0_ &= ~0x00000002;
      chatMsg.clear();
      return this;
    }

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableChatMsg()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChatMsgInfoOuterClass.ChatMsgInfo getChatMsg() {
      return chatMsg;
    }

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public ChatMsgInfoOuterClass.ChatMsgInfo getMutableChatMsg() {
      bitField0_ |= 0x00000002;
      return chatMsg;
    }

    /**
     * <code>optional .ChatMsgInfo chat_msg = 2;</code>
     * @param value the chatMsg to set
     * @return this
     */
    public ChatContentInfo setChatMsg(final ChatMsgInfoOuterClass.ChatMsgInfo value) {
      bitField0_ |= 0x00000002;
      chatMsg.copyFrom(value);
      return this;
    }

    @Override
    public ChatContentInfo copyFrom(final ChatContentInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        msgType = other.msgType;
        chatMsg.copyFrom(other.chatMsg);
      }
      return this;
    }

    @Override
    public ChatContentInfo mergeFrom(final ChatContentInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasMsgType()) {
        setMsgTypeValue(other.msgType);
      }
      if (other.hasChatMsg()) {
        getMutableChatMsg().mergeFrom(other.chatMsg);
      }
      return this;
    }

    @Override
    public ChatContentInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      msgType = 0;
      chatMsg.clear();
      return this;
    }

    @Override
    public ChatContentInfo clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      chatMsg.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ChatContentInfo)) {
        return false;
      }
      ChatContentInfo other = (ChatContentInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasMsgType() || msgType == other.msgType)
        && (!hasChatMsg() || chatMsg.equals(other.chatMsg));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeEnumNoTag(msgType);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 18);
        output.writeMessageNoTag(chatMsg);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(msgType);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(chatMsg);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ChatContentInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // msgType
            final int value = input.readInt32();
            if (MsgTypeOuterClass.MsgType.forNumber(value) != null) {
              msgType = value;
              bitField0_ |= 0x00000001;
            }
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // chatMsg
            input.readMessage(chatMsg);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeEnum(FieldNames.msgType, msgType, MsgTypeOuterClass.MsgType.converter());
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.chatMsg, chatMsg);
      }
      output.endObject();
    }

    @Override
    public ChatContentInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1343750747:
          case -1283380936: {
            if (input.isAtField(FieldNames.msgType)) {
              if (!input.trySkipNullValue()) {
                final MsgTypeOuterClass.MsgType value = input.readEnum(MsgTypeOuterClass.MsgType.converter());
                if (value != null) {
                  msgType = value.getNumber();
                  bitField0_ |= 0x00000001;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 739097865:
          case 1437728282: {
            if (input.isAtField(FieldNames.chatMsg)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(chatMsg);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

    @Override
    public ChatContentInfo clone() {
      return new ChatContentInfo().copyFrom(this);
    }

    @Override
    public boolean isEmpty() {
      return ((bitField0_) == 0);
    }

    public static ChatContentInfo parseFrom(final byte[] data) throws
        InvalidProtocolBufferException {
      return ProtoMessage.mergeFrom(new ChatContentInfo(), data).checkInitialized();
    }

    public static ChatContentInfo parseFrom(final ProtoSource input) throws IOException {
      return ProtoMessage.mergeFrom(new ChatContentInfo(), input).checkInitialized();
    }

    public static ChatContentInfo parseFrom(final JsonSource input) throws IOException {
      return ProtoMessage.mergeFrom(new ChatContentInfo(), input).checkInitialized();
    }

    /**
     * @return factory for creating ChatContentInfo messages
     */
    public static MessageFactory<ChatContentInfo> getFactory() {
      return ChatContentInfoFactory.INSTANCE;
    }

    private enum ChatContentInfoFactory implements MessageFactory<ChatContentInfo> {
      INSTANCE;

      @Override
      public ChatContentInfo create() {
        return ChatContentInfo.newInstance();
      }
    }

    /**
     * Contains name constants used for serializing JSON
     */
    static class FieldNames {
      static final FieldName msgType = FieldName.forField("msgType", "msg_type");

      static final FieldName chatMsg = FieldName.forField("chatMsg", "chat_msg");
    }
  }
}
