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

    /**
     * <code>optional uint32 cocoon_id = 3;</code>
     */
    private int cocoonId;

    /**
     * <code>optional uint32 wave = 4;</code>
     */
    private int wave;

    /**
     * <code>optional uint32 wave_count = 7;</code>
     */
    private int waveCount;

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

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</code>
     */
    private final SceneBattleInfoOuterClass.SceneBattleInfo battleInfo = SceneBattleInfoOuterClass.SceneBattleInfo.newInstance();

    private QuickStartCocoonStageScRsp() {
    }

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

    /**
     * <code>optional uint32 cocoon_id = 3;</code>
     * @return whether the cocoonId field is set
     */
    public boolean hasCocoonId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 cocoon_id = 3;</code>
     * @return this
     */
    public QuickStartCocoonStageScRsp clearCocoonId() {
      bitField0_ &= ~0x00000001;
      cocoonId = 0;
      return this;
    }

    /**
     * <code>optional uint32 cocoon_id = 3;</code>
     * @return the cocoonId
     */
    public int getCocoonId() {
      return cocoonId;
    }

    /**
     * <code>optional uint32 cocoon_id = 3;</code>
     * @param value the cocoonId to set
     * @return this
     */
    public QuickStartCocoonStageScRsp setCocoonId(final int value) {
      bitField0_ |= 0x00000001;
      cocoonId = value;
      return this;
    }

    /**
     * <code>optional uint32 wave = 4;</code>
     * @return whether the wave field is set
     */
    public boolean hasWave() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 wave = 4;</code>
     * @return this
     */
    public QuickStartCocoonStageScRsp clearWave() {
      bitField0_ &= ~0x00000002;
      wave = 0;
      return this;
    }

    /**
     * <code>optional uint32 wave = 4;</code>
     * @return the wave
     */
    public int getWave() {
      return wave;
    }

    /**
     * <code>optional uint32 wave = 4;</code>
     * @param value the wave to set
     * @return this
     */
    public QuickStartCocoonStageScRsp setWave(final int value) {
      bitField0_ |= 0x00000002;
      wave = value;
      return this;
    }

    /**
     * <code>optional uint32 wave_count = 7;</code>
     * @return whether the waveCount field is set
     */
    public boolean hasWaveCount() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 wave_count = 7;</code>
     * @return this
     */
    public QuickStartCocoonStageScRsp clearWaveCount() {
      bitField0_ &= ~0x00000004;
      waveCount = 0;
      return this;
    }

    /**
     * <code>optional uint32 wave_count = 7;</code>
     * @return the waveCount
     */
    public int getWaveCount() {
      return waveCount;
    }

    /**
     * <code>optional uint32 wave_count = 7;</code>
     * @param value the waveCount to set
     * @return this
     */
    public QuickStartCocoonStageScRsp setWaveCount(final int value) {
      bitField0_ |= 0x00000004;
      waveCount = value;
      return this;
    }

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

    /**
     * <code>optional uint32 retcode = 14;</code>
     * @return this
     */
    public QuickStartCocoonStageScRsp clearRetcode() {
      bitField0_ &= ~0x00000008;
      retcode = 0;
      return this;
    }

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

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

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</code>
     * @return whether the battleInfo field is set
     */
    public boolean hasBattleInfo() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</code>
     * @return this
     */
    public QuickStartCocoonStageScRsp clearBattleInfo() {
      bitField0_ &= ~0x00000010;
      battleInfo.clear();
      return this;
    }

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</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 #getMutableBattleInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public SceneBattleInfoOuterClass.SceneBattleInfo getBattleInfo() {
      return battleInfo;
    }

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</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 SceneBattleInfoOuterClass.SceneBattleInfo getMutableBattleInfo() {
      bitField0_ |= 0x00000010;
      return battleInfo;
    }

    /**
     * <code>optional .SceneBattleInfo battle_info = 5;</code>
     * @param value the battleInfo to set
     * @return this
     */
    public QuickStartCocoonStageScRsp setBattleInfo(
        final SceneBattleInfoOuterClass.SceneBattleInfo value) {
      bitField0_ |= 0x00000010;
      battleInfo.copyFrom(value);
      return this;
    }

    @Override
    public QuickStartCocoonStageScRsp copyFrom(final QuickStartCocoonStageScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        cocoonId = other.cocoonId;
        wave = other.wave;
        waveCount = other.waveCount;
        retcode = other.retcode;
        battleInfo.copyFrom(other.battleInfo);
      }
      return this;
    }

    @Override
    public QuickStartCocoonStageScRsp mergeFrom(final QuickStartCocoonStageScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasCocoonId()) {
        setCocoonId(other.cocoonId);
      }
      if (other.hasWave()) {
        setWave(other.wave);
      }
      if (other.hasWaveCount()) {
        setWaveCount(other.waveCount);
      }
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasBattleInfo()) {
        getMutableBattleInfo().mergeFrom(other.battleInfo);
      }
      return this;
    }

    @Override
    public QuickStartCocoonStageScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      cocoonId = 0;
      wave = 0;
      waveCount = 0;
      retcode = 0;
      battleInfo.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof QuickStartCocoonStageScRsp)) {
        return false;
      }
      QuickStartCocoonStageScRsp other = (QuickStartCocoonStageScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasCocoonId() || cocoonId == other.cocoonId)
        && (!hasWave() || wave == other.wave)
        && (!hasWaveCount() || waveCount == other.waveCount)
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasBattleInfo() || battleInfo.equals(other.battleInfo));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(cocoonId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(wave);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 56);
        output.writeUInt32NoTag(waveCount);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 42);
        output.writeMessageNoTag(battleInfo);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(cocoonId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(wave);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(waveCount);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(battleInfo);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public QuickStartCocoonStageScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // cocoonId
            cocoonId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // wave
            wave = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 56) {
              break;
            }
          }
          case 56: {
            // waveCount
            waveCount = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 42) {
              break;
            }
          }
          case 42: {
            // battleInfo
            input.readMessage(battleInfo);
            bitField0_ |= 0x00000010;
            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.cocoonId, cocoonId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.wave, wave);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.waveCount, waveCount);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeMessage(FieldNames.battleInfo, battleInfo);
      }
      output.endObject();
    }

    @Override
    public QuickStartCocoonStageScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -886563534:
          case -1713644381: {
            if (input.isAtField(FieldNames.cocoonId)) {
              if (!input.trySkipNullValue()) {
                cocoonId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3642105: {
            if (input.isAtField(FieldNames.wave)) {
              if (!input.trySkipNullValue()) {
                wave = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1518256534:
          case 611674185: {
            if (input.isAtField(FieldNames.waveCount)) {
              if (!input.trySkipNullValue()) {
                waveCount = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2053377414:
          case -749633579: {
            if (input.isAtField(FieldNames.battleInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(battleInfo);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum QuickStartCocoonStageScRspFactory implements MessageFactory<QuickStartCocoonStageScRsp> {
      INSTANCE;

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

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

      static final FieldName wave = FieldName.forField("wave");

      static final FieldName waveCount = FieldName.forField("waveCount", "wave_count");

      static final FieldName retcode = FieldName.forField("retcode");

      static final FieldName battleInfo = FieldName.forField("battleInfo", "battle_info");
    }
  }
}
