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

    /**
     * <code>repeated uint32 npc_id_list = 4;</code>
     */
    private final RepeatedInt npcIdList = RepeatedInt.newEmptyInstance();

    private GetFirstTalkNpcCsReq() {
    }

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

    /**
     * <code>repeated uint32 npc_id_list = 4;</code>
     * @return whether the npcIdList field is set
     */
    public boolean hasNpcIdList() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>repeated uint32 npc_id_list = 4;</code>
     * @return this
     */
    public GetFirstTalkNpcCsReq clearNpcIdList() {
      bitField0_ &= ~0x00000001;
      npcIdList.clear();
      return this;
    }

    /**
     * <code>repeated uint32 npc_id_list = 4;</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 #getMutableNpcIdList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getNpcIdList() {
      return npcIdList;
    }

    /**
     * <code>repeated uint32 npc_id_list = 4;</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 getMutableNpcIdList() {
      bitField0_ |= 0x00000001;
      return npcIdList;
    }

    /**
     * <code>repeated uint32 npc_id_list = 4;</code>
     * @param value the npcIdList to add
     * @return this
     */
    public GetFirstTalkNpcCsReq addNpcIdList(final int value) {
      bitField0_ |= 0x00000001;
      npcIdList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 npc_id_list = 4;</code>
     * @param values the npcIdList to add
     * @return this
     */
    public GetFirstTalkNpcCsReq addAllNpcIdList(final int... values) {
      bitField0_ |= 0x00000001;
      npcIdList.addAll(values);
      return this;
    }

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

    @Override
    public GetFirstTalkNpcCsReq mergeFrom(final GetFirstTalkNpcCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNpcIdList()) {
        getMutableNpcIdList().addAll(other.npcIdList);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetFirstTalkNpcCsReq)) {
        return false;
      }
      GetFirstTalkNpcCsReq other = (GetFirstTalkNpcCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasNpcIdList() || npcIdList.equals(other.npcIdList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        for (int i = 0; i < npcIdList.length(); i++) {
          output.writeRawByte((byte) 32);
          output.writeUInt32NoTag(npcIdList.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += (1 * npcIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(npcIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetFirstTalkNpcCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 34: {
            // npcIdList [packed=true]
            input.readPackedUInt32(npcIdList, tag);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 32: {
            // npcIdList [packed=false]
            tag = input.readRepeatedUInt32(npcIdList, tag);
            bitField0_ |= 0x00000001;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRepeatedUInt32(FieldNames.npcIdList, npcIdList);
      }
      output.endObject();
    }

    @Override
    public GetFirstTalkNpcCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 522933914:
          case 535639524: {
            if (input.isAtField(FieldNames.npcIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(npcIdList);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetFirstTalkNpcCsReqFactory implements MessageFactory<GetFirstTalkNpcCsReq> {
      INSTANCE;

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

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