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

    /**
     * <code>optional uint32 retcode = 8;</code>
     */
    private int retcode;

    /**
     * <code>optional uint32 cur_mission_id = 13;</code>
     */
    private int curMissionId;

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</code>
     */
    private final RepeatedMessage<MainMissionDataOuterClass.MainMissionData> mainMissionList = RepeatedMessage.newEmptyInstance(MainMissionDataOuterClass.MainMissionData.getFactory());

    /**
     * <code>repeated .Mission mission_list = 9;</code>
     */
    private final RepeatedMessage<MissionOuterClass.Mission> missionList = RepeatedMessage.newEmptyInstance(MissionOuterClass.Mission.getFactory());

    private GetMissionDataScRsp() {
    }

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

    /**
     * <code>optional uint32 retcode = 8;</code>
     * @return whether the retcode field is set
     */
    public boolean hasRetcode() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 retcode = 8;</code>
     * @return this
     */
    public GetMissionDataScRsp clearRetcode() {
      bitField0_ &= ~0x00000001;
      retcode = 0;
      return this;
    }

    /**
     * <code>optional uint32 retcode = 8;</code>
     * @return the retcode
     */
    public int getRetcode() {
      return retcode;
    }

    /**
     * <code>optional uint32 retcode = 8;</code>
     * @param value the retcode to set
     * @return this
     */
    public GetMissionDataScRsp setRetcode(final int value) {
      bitField0_ |= 0x00000001;
      retcode = value;
      return this;
    }

    /**
     * <code>optional uint32 cur_mission_id = 13;</code>
     * @return whether the curMissionId field is set
     */
    public boolean hasCurMissionId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 cur_mission_id = 13;</code>
     * @return this
     */
    public GetMissionDataScRsp clearCurMissionId() {
      bitField0_ &= ~0x00000002;
      curMissionId = 0;
      return this;
    }

    /**
     * <code>optional uint32 cur_mission_id = 13;</code>
     * @return the curMissionId
     */
    public int getCurMissionId() {
      return curMissionId;
    }

    /**
     * <code>optional uint32 cur_mission_id = 13;</code>
     * @param value the curMissionId to set
     * @return this
     */
    public GetMissionDataScRsp setCurMissionId(final int value) {
      bitField0_ |= 0x00000002;
      curMissionId = value;
      return this;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</code>
     * @return whether the mainMissionList field is set
     */
    public boolean hasMainMissionList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</code>
     * @return this
     */
    public GetMissionDataScRsp clearMainMissionList() {
      bitField0_ &= ~0x00000004;
      mainMissionList.clear();
      return this;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</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 #getMutableMainMissionList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<MainMissionDataOuterClass.MainMissionData> getMainMissionList() {
      return mainMissionList;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</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<MainMissionDataOuterClass.MainMissionData> getMutableMainMissionList() {
      bitField0_ |= 0x00000004;
      return mainMissionList;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</code>
     * @param value the mainMissionList to add
     * @return this
     */
    public GetMissionDataScRsp addMainMissionList(
        final MainMissionDataOuterClass.MainMissionData value) {
      bitField0_ |= 0x00000004;
      mainMissionList.add(value);
      return this;
    }

    /**
     * <code>repeated .MainMissionData main_mission_list = 1;</code>
     * @param values the mainMissionList to add
     * @return this
     */
    public GetMissionDataScRsp addAllMainMissionList(
        final MainMissionDataOuterClass.MainMissionData... values) {
      bitField0_ |= 0x00000004;
      mainMissionList.addAll(values);
      return this;
    }

    /**
     * <code>repeated .Mission mission_list = 9;</code>
     * @return whether the missionList field is set
     */
    public boolean hasMissionList() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated .Mission mission_list = 9;</code>
     * @return this
     */
    public GetMissionDataScRsp clearMissionList() {
      bitField0_ &= ~0x00000008;
      missionList.clear();
      return this;
    }

    /**
     * <code>repeated .Mission mission_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 #getMutableMissionList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<MissionOuterClass.Mission> getMissionList() {
      return missionList;
    }

    /**
     * <code>repeated .Mission mission_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<MissionOuterClass.Mission> getMutableMissionList() {
      bitField0_ |= 0x00000008;
      return missionList;
    }

    /**
     * <code>repeated .Mission mission_list = 9;</code>
     * @param value the missionList to add
     * @return this
     */
    public GetMissionDataScRsp addMissionList(final MissionOuterClass.Mission value) {
      bitField0_ |= 0x00000008;
      missionList.add(value);
      return this;
    }

    /**
     * <code>repeated .Mission mission_list = 9;</code>
     * @param values the missionList to add
     * @return this
     */
    public GetMissionDataScRsp addAllMissionList(final MissionOuterClass.Mission... values) {
      bitField0_ |= 0x00000008;
      missionList.addAll(values);
      return this;
    }

    @Override
    public GetMissionDataScRsp copyFrom(final GetMissionDataScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        curMissionId = other.curMissionId;
        mainMissionList.copyFrom(other.mainMissionList);
        missionList.copyFrom(other.missionList);
      }
      return this;
    }

    @Override
    public GetMissionDataScRsp mergeFrom(final GetMissionDataScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasCurMissionId()) {
        setCurMissionId(other.curMissionId);
      }
      if (other.hasMainMissionList()) {
        getMutableMainMissionList().addAll(other.mainMissionList);
      }
      if (other.hasMissionList()) {
        getMutableMissionList().addAll(other.missionList);
      }
      return this;
    }

    @Override
    public GetMissionDataScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      curMissionId = 0;
      mainMissionList.clear();
      missionList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetMissionDataScRsp)) {
        return false;
      }
      GetMissionDataScRsp other = (GetMissionDataScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasCurMissionId() || curMissionId == other.curMissionId)
        && (!hasMainMissionList() || mainMissionList.equals(other.mainMissionList))
        && (!hasMissionList() || missionList.equals(other.missionList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 104);
        output.writeUInt32NoTag(curMissionId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < mainMissionList.length(); i++) {
          output.writeRawByte((byte) 10);
          output.writeMessageNoTag(mainMissionList.get(i));
        }
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < missionList.length(); i++) {
          output.writeRawByte((byte) 74);
          output.writeMessageNoTag(missionList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(curMissionId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * mainMissionList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(mainMissionList);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * missionList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(missionList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetMissionDataScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 64: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 104) {
              break;
            }
          }
          case 104: {
            // curMissionId
            curMissionId = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // mainMissionList
            tag = input.readRepeatedMessage(mainMissionList, tag);
            bitField0_ |= 0x00000004;
            if (tag != 74) {
              break;
            }
          }
          case 74: {
            // missionList
            tag = input.readRepeatedMessage(missionList, tag);
            bitField0_ |= 0x00000008;
            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.retcode, retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.curMissionId, curMissionId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.mainMissionList, mainMissionList);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedMessage(FieldNames.missionList, missionList);
      }
      output.endObject();
    }

    @Override
    public GetMissionDataScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1870430873:
          case 50847757: {
            if (input.isAtField(FieldNames.curMissionId)) {
              if (!input.trySkipNullValue()) {
                curMissionId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1352596271:
          case 939604023: {
            if (input.isAtField(FieldNames.mainMissionList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(mainMissionList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1383006282:
          case -58851471: {
            if (input.isAtField(FieldNames.missionList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(missionList);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetMissionDataScRspFactory implements MessageFactory<GetMissionDataScRsp> {
      INSTANCE;

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

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

      static final FieldName curMissionId = FieldName.forField("curMissionId", "cur_mission_id");

      static final FieldName mainMissionList = FieldName.forField("mainMissionList", "main_mission_list");

      static final FieldName missionList = FieldName.forField("missionList", "mission_list");
    }
  }
}
