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

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

    /**
     * <code>optional .ItemList reward = 1;</code>
     */
    private final ItemListOuterClass.ItemList reward = ItemListOuterClass.ItemList.newInstance();

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</code>
     */
    private final TutorialGuideOuterClass.TutorialGuide tutorialGuide = TutorialGuideOuterClass.TutorialGuide.newInstance();

    private FinishTutorialGuideScRsp() {
    }

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

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

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

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

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

    /**
     * <code>optional .ItemList reward = 1;</code>
     * @return whether the reward field is set
     */
    public boolean hasReward() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .ItemList reward = 1;</code>
     * @return this
     */
    public FinishTutorialGuideScRsp clearReward() {
      bitField0_ &= ~0x00000002;
      reward.clear();
      return this;
    }

    /**
     * <code>optional .ItemList reward = 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 #getMutableReward()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ItemListOuterClass.ItemList getReward() {
      return reward;
    }

    /**
     * <code>optional .ItemList reward = 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 ItemListOuterClass.ItemList getMutableReward() {
      bitField0_ |= 0x00000002;
      return reward;
    }

    /**
     * <code>optional .ItemList reward = 1;</code>
     * @param value the reward to set
     * @return this
     */
    public FinishTutorialGuideScRsp setReward(final ItemListOuterClass.ItemList value) {
      bitField0_ |= 0x00000002;
      reward.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</code>
     * @return whether the tutorialGuide field is set
     */
    public boolean hasTutorialGuide() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</code>
     * @return this
     */
    public FinishTutorialGuideScRsp clearTutorialGuide() {
      bitField0_ &= ~0x00000004;
      tutorialGuide.clear();
      return this;
    }

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</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 #getMutableTutorialGuide()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public TutorialGuideOuterClass.TutorialGuide getTutorialGuide() {
      return tutorialGuide;
    }

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</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 TutorialGuideOuterClass.TutorialGuide getMutableTutorialGuide() {
      bitField0_ |= 0x00000004;
      return tutorialGuide;
    }

    /**
     * <code>optional .TutorialGuide tutorial_guide = 7;</code>
     * @param value the tutorialGuide to set
     * @return this
     */
    public FinishTutorialGuideScRsp setTutorialGuide(
        final TutorialGuideOuterClass.TutorialGuide value) {
      bitField0_ |= 0x00000004;
      tutorialGuide.copyFrom(value);
      return this;
    }

    @Override
    public FinishTutorialGuideScRsp copyFrom(final FinishTutorialGuideScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        reward.copyFrom(other.reward);
        tutorialGuide.copyFrom(other.tutorialGuide);
      }
      return this;
    }

    @Override
    public FinishTutorialGuideScRsp mergeFrom(final FinishTutorialGuideScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasReward()) {
        getMutableReward().mergeFrom(other.reward);
      }
      if (other.hasTutorialGuide()) {
        getMutableTutorialGuide().mergeFrom(other.tutorialGuide);
      }
      return this;
    }

    @Override
    public FinishTutorialGuideScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      reward.clear();
      tutorialGuide.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FinishTutorialGuideScRsp)) {
        return false;
      }
      FinishTutorialGuideScRsp other = (FinishTutorialGuideScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasReward() || reward.equals(other.reward))
        && (!hasTutorialGuide() || tutorialGuide.equals(other.tutorialGuide));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 80);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 10);
        output.writeMessageNoTag(reward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 58);
        output.writeMessageNoTag(tutorialGuide);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(reward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(tutorialGuide);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FinishTutorialGuideScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 80: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // reward
            input.readMessage(reward);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // tutorialGuide
            input.readMessage(tutorialGuide);
            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.retcode, retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.reward, reward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.tutorialGuide, tutorialGuide);
      }
      output.endObject();
    }

    @Override
    public FinishTutorialGuideScRsp 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 -934326481: {
            if (input.isAtField(FieldNames.reward)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(reward);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1686407742:
          case 1413565147: {
            if (input.isAtField(FieldNames.tutorialGuide)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(tutorialGuide);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FinishTutorialGuideScRspFactory implements MessageFactory<FinishTutorialGuideScRsp> {
      INSTANCE;

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

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

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

      static final FieldName tutorialGuide = FieldName.forField("tutorialGuide", "tutorial_guide");
    }
  }
}
