// 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.RepeatedMessage;

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

    /**
     * <code>optional uint64 sent_time = 4;</code>
     */
    private long sentTime;

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</code>
     */
    private final ChatHeaderInfoOuterClass.ChatHeaderInfo chatHeader = ChatHeaderInfoOuterClass.ChatHeaderInfo.newInstance();

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</code>
     */
    private final RepeatedMessage<ChatContentInfoOuterClass.ChatContentInfo> chatContentList = RepeatedMessage.newEmptyInstance(ChatContentInfoOuterClass.ChatContentInfo.getFactory());

    private ChatInfo() {
    }

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

    /**
     * <code>optional uint64 sent_time = 4;</code>
     * @return whether the sentTime field is set
     */
    public boolean hasSentTime() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint64 sent_time = 4;</code>
     * @return this
     */
    public ChatInfo clearSentTime() {
      bitField0_ &= ~0x00000001;
      sentTime = 0L;
      return this;
    }

    /**
     * <code>optional uint64 sent_time = 4;</code>
     * @return the sentTime
     */
    public long getSentTime() {
      return sentTime;
    }

    /**
     * <code>optional uint64 sent_time = 4;</code>
     * @param value the sentTime to set
     * @return this
     */
    public ChatInfo setSentTime(final long value) {
      bitField0_ |= 0x00000001;
      sentTime = value;
      return this;
    }

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</code>
     * @return whether the chatHeader field is set
     */
    public boolean hasChatHeader() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</code>
     * @return this
     */
    public ChatInfo clearChatHeader() {
      bitField0_ &= ~0x00000002;
      chatHeader.clear();
      return this;
    }

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</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 #getMutableChatHeader()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChatHeaderInfoOuterClass.ChatHeaderInfo getChatHeader() {
      return chatHeader;
    }

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</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 ChatHeaderInfoOuterClass.ChatHeaderInfo getMutableChatHeader() {
      bitField0_ |= 0x00000002;
      return chatHeader;
    }

    /**
     * <code>optional .ChatHeaderInfo chat_header = 8;</code>
     * @param value the chatHeader to set
     * @return this
     */
    public ChatInfo setChatHeader(final ChatHeaderInfoOuterClass.ChatHeaderInfo value) {
      bitField0_ |= 0x00000002;
      chatHeader.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</code>
     * @return whether the chatContentList field is set
     */
    public boolean hasChatContentList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</code>
     * @return this
     */
    public ChatInfo clearChatContentList() {
      bitField0_ &= ~0x00000004;
      chatContentList.clear();
      return this;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</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 #getMutableChatContentList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<ChatContentInfoOuterClass.ChatContentInfo> getChatContentList() {
      return chatContentList;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</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 RepeatedMessage<ChatContentInfoOuterClass.ChatContentInfo> getMutableChatContentList() {
      bitField0_ |= 0x00000004;
      return chatContentList;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</code>
     * @param value the chatContentList to add
     * @return this
     */
    public ChatInfo addChatContentList(final ChatContentInfoOuterClass.ChatContentInfo value) {
      bitField0_ |= 0x00000004;
      chatContentList.add(value);
      return this;
    }

    /**
     * <code>repeated .ChatContentInfo chat_content_list = 9;</code>
     * @param values the chatContentList to add
     * @return this
     */
    public ChatInfo addAllChatContentList(
        final ChatContentInfoOuterClass.ChatContentInfo... values) {
      bitField0_ |= 0x00000004;
      chatContentList.addAll(values);
      return this;
    }

    @Override
    public ChatInfo copyFrom(final ChatInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        sentTime = other.sentTime;
        chatHeader.copyFrom(other.chatHeader);
        chatContentList.copyFrom(other.chatContentList);
      }
      return this;
    }

    @Override
    public ChatInfo mergeFrom(final ChatInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasSentTime()) {
        setSentTime(other.sentTime);
      }
      if (other.hasChatHeader()) {
        getMutableChatHeader().mergeFrom(other.chatHeader);
      }
      if (other.hasChatContentList()) {
        getMutableChatContentList().addAll(other.chatContentList);
      }
      return this;
    }

    @Override
    public ChatInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      sentTime = 0L;
      chatHeader.clear();
      chatContentList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ChatInfo)) {
        return false;
      }
      ChatInfo other = (ChatInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasSentTime() || sentTime == other.sentTime)
        && (!hasChatHeader() || chatHeader.equals(other.chatHeader))
        && (!hasChatContentList() || chatContentList.equals(other.chatContentList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt64NoTag(sentTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 66);
        output.writeMessageNoTag(chatHeader);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < chatContentList.length(); i++) {
          output.writeRawByte((byte) 74);
          output.writeMessageNoTag(chatContentList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt64SizeNoTag(sentTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(chatHeader);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * chatContentList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(chatContentList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ChatInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 32: {
            // sentTime
            sentTime = input.readUInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 66) {
              break;
            }
          }
          case 66: {
            // chatHeader
            input.readMessage(chatHeader);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 74) {
              break;
            }
          }
          case 74: {
            // chatContentList
            tag = input.readRepeatedMessage(chatContentList, tag);
            bitField0_ |= 0x00000004;
            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.writeUInt64(FieldNames.sentTime, sentTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.chatHeader, chatHeader);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.chatContentList, chatContentList);
      }
      output.endObject();
    }

    @Override
    public ChatInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1262226053:
          case 484784916: {
            if (input.isAtField(FieldNames.sentTime)) {
              if (!input.trySkipNullValue()) {
                sentTime = input.readUInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1988984827:
          case 1793218900: {
            if (input.isAtField(FieldNames.chatHeader)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(chatHeader);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1437826497:
          case -305783253: {
            if (input.isAtField(FieldNames.chatContentList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(chatContentList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ChatInfoFactory implements MessageFactory<ChatInfo> {
      INSTANCE;

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

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

      static final FieldName chatHeader = FieldName.forField("chatHeader", "chat_header");

      static final FieldName chatContentList = FieldName.forField("chatContentList", "chat_content_list");
    }
  }
}
