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

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

    /**
     * <code>optional .ChatType chat_type = 13;</code>
     */
    private int chatType;

    /**
     * <code>optional .ChatContentInfo chat_content = 8;</code>
     */
    private final ChatContentInfoOuterClass.ChatContentInfo chatContent = ChatContentInfoOuterClass.ChatContentInfo.newInstance();

    /**
     * <code>repeated uint32 to_uid_list = 9;</code>
     */
    private final RepeatedInt toUidList = RepeatedInt.newEmptyInstance();

    private SendMsgCsReq() {
    }

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

    /**
     * <code>optional .ChatType chat_type = 13;</code>
     * @return whether the chatType field is set
     */
    public boolean hasChatType() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .ChatType chat_type = 13;</code>
     * @return this
     */
    public SendMsgCsReq clearChatType() {
      bitField0_ &= ~0x00000001;
      chatType = 0;
      return this;
    }

    /**
     * <code>optional .ChatType chat_type = 13;</code>
     * @return the chatType
     */
    public ChatTypeOuterClass.ChatType getChatType() {
      return ChatTypeOuterClass.ChatType.forNumber(chatType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link SendMsgCsReq#getChatType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getChatTypeValue() {
      return chatType;
    }

    /**
     * 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 ChatTypeOuterClass.ChatType}. Setting an invalid value
     * can cause {@link SendMsgCsReq#getChatType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public SendMsgCsReq setChatTypeValue(final int value) {
      bitField0_ |= 0x00000001;
      chatType = value;
      return this;
    }

    /**
     * <code>optional .ChatType chat_type = 13;</code>
     * @param value the chatType to set
     * @return this
     */
    public SendMsgCsReq setChatType(final ChatTypeOuterClass.ChatType value) {
      bitField0_ |= 0x00000001;
      chatType = value.getNumber();
      return this;
    }

    /**
     * <code>optional .ChatContentInfo chat_content = 8;</code>
     * @return whether the chatContent field is set
     */
    public boolean hasChatContent() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .ChatContentInfo chat_content = 8;</code>
     * @return this
     */
    public SendMsgCsReq clearChatContent() {
      bitField0_ &= ~0x00000002;
      chatContent.clear();
      return this;
    }

    /**
     * <code>optional .ChatContentInfo chat_content = 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 #getMutableChatContent()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChatContentInfoOuterClass.ChatContentInfo getChatContent() {
      return chatContent;
    }

    /**
     * <code>optional .ChatContentInfo chat_content = 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 ChatContentInfoOuterClass.ChatContentInfo getMutableChatContent() {
      bitField0_ |= 0x00000002;
      return chatContent;
    }

    /**
     * <code>optional .ChatContentInfo chat_content = 8;</code>
     * @param value the chatContent to set
     * @return this
     */
    public SendMsgCsReq setChatContent(final ChatContentInfoOuterClass.ChatContentInfo value) {
      bitField0_ |= 0x00000002;
      chatContent.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated uint32 to_uid_list = 9;</code>
     * @return whether the toUidList field is set
     */
    public boolean hasToUidList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated uint32 to_uid_list = 9;</code>
     * @return this
     */
    public SendMsgCsReq clearToUidList() {
      bitField0_ &= ~0x00000004;
      toUidList.clear();
      return this;
    }

    /**
     * <code>repeated uint32 to_uid_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 #getMutableToUidList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getToUidList() {
      return toUidList;
    }

    /**
     * <code>repeated uint32 to_uid_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 RepeatedInt getMutableToUidList() {
      bitField0_ |= 0x00000004;
      return toUidList;
    }

    /**
     * <code>repeated uint32 to_uid_list = 9;</code>
     * @param value the toUidList to add
     * @return this
     */
    public SendMsgCsReq addToUidList(final int value) {
      bitField0_ |= 0x00000004;
      toUidList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 to_uid_list = 9;</code>
     * @param values the toUidList to add
     * @return this
     */
    public SendMsgCsReq addAllToUidList(final int... values) {
      bitField0_ |= 0x00000004;
      toUidList.addAll(values);
      return this;
    }

    @Override
    public SendMsgCsReq copyFrom(final SendMsgCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        chatType = other.chatType;
        chatContent.copyFrom(other.chatContent);
        toUidList.copyFrom(other.toUidList);
      }
      return this;
    }

    @Override
    public SendMsgCsReq mergeFrom(final SendMsgCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasChatType()) {
        setChatTypeValue(other.chatType);
      }
      if (other.hasChatContent()) {
        getMutableChatContent().mergeFrom(other.chatContent);
      }
      if (other.hasToUidList()) {
        getMutableToUidList().addAll(other.toUidList);
      }
      return this;
    }

    @Override
    public SendMsgCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      chatType = 0;
      chatContent.clear();
      toUidList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof SendMsgCsReq)) {
        return false;
      }
      SendMsgCsReq other = (SendMsgCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasChatType() || chatType == other.chatType)
        && (!hasChatContent() || chatContent.equals(other.chatContent))
        && (!hasToUidList() || toUidList.equals(other.toUidList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 104);
        output.writeEnumNoTag(chatType);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 66);
        output.writeMessageNoTag(chatContent);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < toUidList.length(); i++) {
          output.writeRawByte((byte) 72);
          output.writeUInt32NoTag(toUidList.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(chatType);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(chatContent);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * toUidList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(toUidList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public SendMsgCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 104: {
            // chatType
            final int value = input.readInt32();
            if (ChatTypeOuterClass.ChatType.forNumber(value) != null) {
              chatType = value;
              bitField0_ |= 0x00000001;
            }
            tag = input.readTag();
            if (tag != 66) {
              break;
            }
          }
          case 66: {
            // chatContent
            input.readMessage(chatContent);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 74) {
              break;
            }
          }
          case 74: {
            // toUidList [packed=true]
            input.readPackedUInt32(toUidList, tag);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 72: {
            // toUidList [packed=false]
            tag = input.readRepeatedUInt32(toUidList, tag);
            bitField0_ |= 0x00000004;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeEnum(FieldNames.chatType, chatType, ChatTypeOuterClass.ChatType.converter());
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.chatContent, chatContent);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedUInt32(FieldNames.toUidList, toUidList);
      }
      output.endObject();
    }

    @Override
    public SendMsgCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1437412018:
          case 1620118465: {
            if (input.isAtField(FieldNames.chatType)) {
              if (!input.trySkipNullValue()) {
                final ChatTypeOuterClass.ChatType value = input.readEnum(ChatTypeOuterClass.ChatType.converter());
                if (value != null) {
                  chatType = value.getNumber();
                  bitField0_ |= 0x00000001;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1372764671:
          case -88566126: {
            if (input.isAtField(FieldNames.chatContent)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(chatContent);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2098685421:
          case 1162351729: {
            if (input.isAtField(FieldNames.toUidList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(toUidList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SendMsgCsReqFactory implements MessageFactory<SendMsgCsReq> {
      INSTANCE;

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

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

      static final FieldName chatContent = FieldName.forField("chatContent", "chat_content");

      static final FieldName toUidList = FieldName.forField("toUidList", "to_uid_list");
    }
  }
}
