// 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 RevcMsgScNotifyOuterClass {
  /**
   * Protobuf type {@code RevcMsgScNotify}
   */
  public static final class RevcMsgScNotify extends ProtoMessage<RevcMsgScNotify> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional uint32 to_uid = 9;</code>
     */
    private int toUid;

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

    /**
     * <code>optional .ChatInfo msg = 15;</code>
     */
    private final ChatInfoOuterClass.ChatInfo msg = ChatInfoOuterClass.ChatInfo.newInstance();

    private RevcMsgScNotify() {
    }

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

    /**
     * <code>optional uint32 to_uid = 9;</code>
     * @return whether the toUid field is set
     */
    public boolean hasToUid() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 to_uid = 9;</code>
     * @return this
     */
    public RevcMsgScNotify clearToUid() {
      bitField0_ &= ~0x00000001;
      toUid = 0;
      return this;
    }

    /**
     * <code>optional uint32 to_uid = 9;</code>
     * @return the toUid
     */
    public int getToUid() {
      return toUid;
    }

    /**
     * <code>optional uint32 to_uid = 9;</code>
     * @param value the toUid to set
     * @return this
     */
    public RevcMsgScNotify setToUid(final int value) {
      bitField0_ |= 0x00000001;
      toUid = value;
      return this;
    }

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

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

    /**
     * <code>optional .ChatType chat_type = 5;</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 RevcMsgScNotify#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 RevcMsgScNotify#getChatType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public RevcMsgScNotify setChatTypeValue(final int value) {
      bitField0_ |= 0x00000002;
      chatType = value;
      return this;
    }

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

    /**
     * <code>optional .ChatInfo msg = 15;</code>
     * @return whether the msg field is set
     */
    public boolean hasMsg() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .ChatInfo msg = 15;</code>
     * @return this
     */
    public RevcMsgScNotify clearMsg() {
      bitField0_ &= ~0x00000004;
      msg.clear();
      return this;
    }

    /**
     * <code>optional .ChatInfo msg = 15;</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 #getMutableMsg()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChatInfoOuterClass.ChatInfo getMsg() {
      return msg;
    }

    /**
     * <code>optional .ChatInfo msg = 15;</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 ChatInfoOuterClass.ChatInfo getMutableMsg() {
      bitField0_ |= 0x00000004;
      return msg;
    }

    /**
     * <code>optional .ChatInfo msg = 15;</code>
     * @param value the msg to set
     * @return this
     */
    public RevcMsgScNotify setMsg(final ChatInfoOuterClass.ChatInfo value) {
      bitField0_ |= 0x00000004;
      msg.copyFrom(value);
      return this;
    }

    @Override
    public RevcMsgScNotify copyFrom(final RevcMsgScNotify other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        toUid = other.toUid;
        chatType = other.chatType;
        msg.copyFrom(other.msg);
      }
      return this;
    }

    @Override
    public RevcMsgScNotify mergeFrom(final RevcMsgScNotify other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasToUid()) {
        setToUid(other.toUid);
      }
      if (other.hasChatType()) {
        setChatTypeValue(other.chatType);
      }
      if (other.hasMsg()) {
        getMutableMsg().mergeFrom(other.msg);
      }
      return this;
    }

    @Override
    public RevcMsgScNotify clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      toUid = 0;
      chatType = 0;
      msg.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof RevcMsgScNotify)) {
        return false;
      }
      RevcMsgScNotify other = (RevcMsgScNotify) o;
      return bitField0_ == other.bitField0_
        && (!hasToUid() || toUid == other.toUid)
        && (!hasChatType() || chatType == other.chatType)
        && (!hasMsg() || msg.equals(other.msg));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 72);
        output.writeUInt32NoTag(toUid);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 40);
        output.writeEnumNoTag(chatType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 122);
        output.writeMessageNoTag(msg);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(toUid);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(chatType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(msg);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public RevcMsgScNotify mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 72: {
            // toUid
            toUid = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // chatType
            final int value = input.readInt32();
            if (ChatTypeOuterClass.ChatType.forNumber(value) != null) {
              chatType = value;
              bitField0_ |= 0x00000002;
            }
            tag = input.readTag();
            if (tag != 122) {
              break;
            }
          }
          case 122: {
            // msg
            input.readMessage(msg);
            bitField0_ |= 0x00000004;
            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.toUid, toUid);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeEnum(FieldNames.chatType, chatType, ChatTypeOuterClass.ChatType.converter());
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.msg, msg);
      }
      output.endObject();
    }

    @Override
    public RevcMsgScNotify mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 110520277:
          case -868529012: {
            if (input.isAtField(FieldNames.toUid)) {
              if (!input.trySkipNullValue()) {
                toUid = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          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_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 108417: {
            if (input.isAtField(FieldNames.msg)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(msg);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum RevcMsgScNotifyFactory implements MessageFactory<RevcMsgScNotify> {
      INSTANCE;

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

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

      static final FieldName chatType = FieldName.forField("chatType", "chat_type");

      static final FieldName msg = FieldName.forField("msg");
    }
  }
}
