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

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

    /**
     * <code>optional .HeroBasicType basic_type = 8;</code>
     */
    private int basicType;

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

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</code>
     */
    private final RepeatedInt unlockedBasicTypes = RepeatedInt.newEmptyInstance();

    private UnlockHeroBasicTypeScRsp() {
    }

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

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

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

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

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

    /**
     * <code>optional .HeroBasicType basic_type = 8;</code>
     * @return whether the basicType field is set
     */
    public boolean hasBasicType() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 8;</code>
     * @return this
     */
    public UnlockHeroBasicTypeScRsp clearBasicType() {
      bitField0_ &= ~0x00000002;
      basicType = 0;
      return this;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 8;</code>
     * @return the basicType
     */
    public HeroBasicTypeOuterClass.HeroBasicType getBasicType() {
      return HeroBasicTypeOuterClass.HeroBasicType.forNumber(basicType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link UnlockHeroBasicTypeScRsp#getBasicType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getBasicTypeValue() {
      return basicType;
    }

    /**
     * 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 HeroBasicTypeOuterClass.HeroBasicType}. Setting an invalid value
     * can cause {@link UnlockHeroBasicTypeScRsp#getBasicType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public UnlockHeroBasicTypeScRsp setBasicTypeValue(final int value) {
      bitField0_ |= 0x00000002;
      basicType = value;
      return this;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 8;</code>
     * @param value the basicType to set
     * @return this
     */
    public UnlockHeroBasicTypeScRsp setBasicType(
        final HeroBasicTypeOuterClass.HeroBasicType value) {
      bitField0_ |= 0x00000002;
      basicType = value.getNumber();
      return this;
    }

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

    /**
     * <code>optional .ItemList reward = 1;</code>
     * @return this
     */
    public UnlockHeroBasicTypeScRsp clearReward() {
      bitField0_ &= ~0x00000004;
      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_ |= 0x00000004;
      return reward;
    }

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

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</code>
     * @return whether the unlockedBasicTypes field is set
     */
    public boolean hasUnlockedBasicTypes() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</code>
     * @return this
     */
    public UnlockHeroBasicTypeScRsp clearUnlockedBasicTypes() {
      bitField0_ &= ~0x00000008;
      unlockedBasicTypes.clear();
      return this;
    }

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</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 #getMutableUnlockedBasicTypes()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getUnlockedBasicTypes() {
      return unlockedBasicTypes;
    }

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</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 getMutableUnlockedBasicTypes() {
      bitField0_ |= 0x00000008;
      return unlockedBasicTypes;
    }

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</code>
     * @param value the unlockedBasicTypes to add
     * @return this
     */
    public UnlockHeroBasicTypeScRsp addUnlockedBasicTypes(final int value) {
      bitField0_ |= 0x00000008;
      unlockedBasicTypes.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 unlocked_basic_types = 12;</code>
     * @param values the unlockedBasicTypes to add
     * @return this
     */
    public UnlockHeroBasicTypeScRsp addAllUnlockedBasicTypes(final int... values) {
      bitField0_ |= 0x00000008;
      unlockedBasicTypes.addAll(values);
      return this;
    }

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

    @Override
    public UnlockHeroBasicTypeScRsp mergeFrom(final UnlockHeroBasicTypeScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasBasicType()) {
        setBasicTypeValue(other.basicType);
      }
      if (other.hasReward()) {
        getMutableReward().mergeFrom(other.reward);
      }
      if (other.hasUnlockedBasicTypes()) {
        getMutableUnlockedBasicTypes().addAll(other.unlockedBasicTypes);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof UnlockHeroBasicTypeScRsp)) {
        return false;
      }
      UnlockHeroBasicTypeScRsp other = (UnlockHeroBasicTypeScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasBasicType() || basicType == other.basicType)
        && (!hasReward() || reward.equals(other.reward))
        && (!hasUnlockedBasicTypes() || unlockedBasicTypes.equals(other.unlockedBasicTypes));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 64);
        output.writeEnumNoTag(basicType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 10);
        output.writeMessageNoTag(reward);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < unlockedBasicTypes.length(); i++) {
          output.writeRawByte((byte) 96);
          output.writeUInt32NoTag(unlockedBasicTypes.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(basicType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(reward);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * unlockedBasicTypes.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(unlockedBasicTypes);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public UnlockHeroBasicTypeScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // basicType
            final int value = input.readInt32();
            if (HeroBasicTypeOuterClass.HeroBasicType.forNumber(value) != null) {
              basicType = value;
              bitField0_ |= 0x00000002;
            }
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // reward
            input.readMessage(reward);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 98) {
              break;
            }
          }
          case 98: {
            // unlockedBasicTypes [packed=true]
            input.readPackedUInt32(unlockedBasicTypes, tag);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 96: {
            // unlockedBasicTypes [packed=false]
            tag = input.readRepeatedUInt32(unlockedBasicTypes, tag);
            bitField0_ |= 0x00000008;
            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.writeEnum(FieldNames.basicType, basicType, HeroBasicTypeOuterClass.HeroBasicType.converter());
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.reward, reward);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedUInt32(FieldNames.unlockedBasicTypes, unlockedBasicTypes);
      }
      output.endObject();
    }

    @Override
    public UnlockHeroBasicTypeScRsp 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 -1699147640:
          case -1123950421: {
            if (input.isAtField(FieldNames.basicType)) {
              if (!input.trySkipNullValue()) {
                final HeroBasicTypeOuterClass.HeroBasicType value = input.readEnum(HeroBasicTypeOuterClass.HeroBasicType.converter());
                if (value != null) {
                  basicType = value.getNumber();
                  bitField0_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -934326481: {
            if (input.isAtField(FieldNames.reward)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(reward);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 243664942:
          case -212631092: {
            if (input.isAtField(FieldNames.unlockedBasicTypes)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(unlockedBasicTypes);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum UnlockHeroBasicTypeScRspFactory implements MessageFactory<UnlockHeroBasicTypeScRsp> {
      INSTANCE;

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

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

      static final FieldName basicType = FieldName.forField("basicType", "basic_type");

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

      static final FieldName unlockedBasicTypes = FieldName.forField("unlockedBasicTypes", "unlocked_basic_types");
    }
  }
}
