// 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;
import us.hebi.quickbuf.Utf8String;

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

    /**
     * <code>optional uint32 emote_id = 104;</code>
     */
    private int emoteId;

    /**
     * <code>optional string chat_text = 103;</code>
     */
    private final Utf8String chatText = Utf8String.newEmptyInstance();

    private ChatMsgInfo() {
    }

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

    /**
     * <code>optional uint32 emote_id = 104;</code>
     * @return whether the emoteId field is set
     */
    public boolean hasEmoteId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 emote_id = 104;</code>
     * @return this
     */
    public ChatMsgInfo clearEmoteId() {
      bitField0_ &= ~0x00000001;
      emoteId = 0;
      return this;
    }

    /**
     * <code>optional uint32 emote_id = 104;</code>
     * @return the emoteId
     */
    public int getEmoteId() {
      return emoteId;
    }

    /**
     * <code>optional uint32 emote_id = 104;</code>
     * @param value the emoteId to set
     * @return this
     */
    public ChatMsgInfo setEmoteId(final int value) {
      bitField0_ |= 0x00000001;
      emoteId = value;
      return this;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @return whether the chatText field is set
     */
    public boolean hasChatText() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @return this
     */
    public ChatMsgInfo clearChatText() {
      bitField0_ &= ~0x00000002;
      chatText.clear();
      return this;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @return the chatText
     */
    public String getChatText() {
      return chatText.getString();
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @return internal {@code Utf8String} representation of chatText for reading
     */
    public Utf8String getChatTextBytes() {
      return this.chatText;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @return internal {@code Utf8String} representation of chatText for modifications
     */
    public Utf8String getMutableChatTextBytes() {
      bitField0_ |= 0x00000002;
      return this.chatText;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @param value the chatText to set
     * @return this
     */
    public ChatMsgInfo setChatText(final CharSequence value) {
      bitField0_ |= 0x00000002;
      chatText.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string chat_text = 103;</code>
     * @param value the chatText to set
     * @return this
     */
    public ChatMsgInfo setChatText(final Utf8String value) {
      bitField0_ |= 0x00000002;
      chatText.copyFrom(value);
      return this;
    }

    @Override
    public ChatMsgInfo copyFrom(final ChatMsgInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        emoteId = other.emoteId;
        chatText.copyFrom(other.chatText);
      }
      return this;
    }

    @Override
    public ChatMsgInfo mergeFrom(final ChatMsgInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasEmoteId()) {
        setEmoteId(other.emoteId);
      }
      if (other.hasChatText()) {
        getMutableChatTextBytes().copyFrom(other.chatText);
      }
      return this;
    }

    @Override
    public ChatMsgInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      emoteId = 0;
      chatText.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ChatMsgInfo)) {
        return false;
      }
      ChatMsgInfo other = (ChatMsgInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasEmoteId() || emoteId == other.emoteId)
        && (!hasChatText() || chatText.equals(other.chatText));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 1728);
        output.writeUInt32NoTag(emoteId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawLittleEndian16((short) 1722);
        output.writeStringNoTag(chatText);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeUInt32SizeNoTag(emoteId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 2 + ProtoSink.computeStringSizeNoTag(chatText);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ChatMsgInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 832: {
            // emoteId
            emoteId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 826) {
              break;
            }
          }
          case 826: {
            // chatText
            input.readString(chatText);
            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.writeUInt32(FieldNames.emoteId, emoteId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeString(FieldNames.chatText, chatText);
      }
      output.endObject();
    }

    @Override
    public ChatMsgInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1624765261:
          case 1171905858: {
            if (input.isAtField(FieldNames.emoteId)) {
              if (!input.trySkipNullValue()) {
                emoteId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1437393061:
          case 1620099508: {
            if (input.isAtField(FieldNames.chatText)) {
              if (!input.trySkipNullValue()) {
                input.readString(chatText);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ChatMsgInfoFactory implements MessageFactory<ChatMsgInfo> {
      INSTANCE;

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

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

      static final FieldName chatText = FieldName.forField("chatText", "chat_text");
    }
  }
}
