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

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

    /**
     * <code>optional .MultiPathAvatarType avatar_id = 2;</code>
     */
    private int avatarId;

    /**
     * <code>optional .ItemList reward_list = 9;</code>
     */
    private final ItemListOuterClass.ItemList rewardList = ItemListOuterClass.ItemList.newInstance();

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</code>
     */
    private final RepeatedInt basicTypeIdList = RepeatedInt.newEmptyInstance();

    private UnlockAvatarPathScRsp() {
    }

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

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

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

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

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

    /**
     * <code>optional .MultiPathAvatarType avatar_id = 2;</code>
     * @return whether the avatarId field is set
     */
    public boolean hasAvatarId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .MultiPathAvatarType avatar_id = 2;</code>
     * @return this
     */
    public UnlockAvatarPathScRsp clearAvatarId() {
      bitField0_ &= ~0x00000002;
      avatarId = 0;
      return this;
    }

    /**
     * <code>optional .MultiPathAvatarType avatar_id = 2;</code>
     * @return the avatarId
     */
    public MultiPathAvatarTypeOuterClass.MultiPathAvatarType getAvatarId() {
      return MultiPathAvatarTypeOuterClass.MultiPathAvatarType.forNumber(avatarId);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link UnlockAvatarPathScRsp#getAvatarId()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getAvatarIdValue() {
      return avatarId;
    }

    /**
     * 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 MultiPathAvatarTypeOuterClass.MultiPathAvatarType}. Setting an invalid value
     * can cause {@link UnlockAvatarPathScRsp#getAvatarId()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public UnlockAvatarPathScRsp setAvatarIdValue(final int value) {
      bitField0_ |= 0x00000002;
      avatarId = value;
      return this;
    }

    /**
     * <code>optional .MultiPathAvatarType avatar_id = 2;</code>
     * @param value the avatarId to set
     * @return this
     */
    public UnlockAvatarPathScRsp setAvatarId(
        final MultiPathAvatarTypeOuterClass.MultiPathAvatarType value) {
      bitField0_ |= 0x00000002;
      avatarId = value.getNumber();
      return this;
    }

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

    /**
     * <code>optional .ItemList reward_list = 9;</code>
     * @return this
     */
    public UnlockAvatarPathScRsp clearRewardList() {
      bitField0_ &= ~0x00000004;
      rewardList.clear();
      return this;
    }

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

    /**
     * <code>optional .ItemList reward_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 ItemListOuterClass.ItemList getMutableRewardList() {
      bitField0_ |= 0x00000004;
      return rewardList;
    }

    /**
     * <code>optional .ItemList reward_list = 9;</code>
     * @param value the rewardList to set
     * @return this
     */
    public UnlockAvatarPathScRsp setRewardList(final ItemListOuterClass.ItemList value) {
      bitField0_ |= 0x00000004;
      rewardList.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</code>
     * @return whether the basicTypeIdList field is set
     */
    public boolean hasBasicTypeIdList() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</code>
     * @return this
     */
    public UnlockAvatarPathScRsp clearBasicTypeIdList() {
      bitField0_ &= ~0x00000008;
      basicTypeIdList.clear();
      return this;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</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 #getMutableBasicTypeIdList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getBasicTypeIdList() {
      return basicTypeIdList;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</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 getMutableBasicTypeIdList() {
      bitField0_ |= 0x00000008;
      return basicTypeIdList;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</code>
     * @param value the basicTypeIdList to add
     * @return this
     */
    public UnlockAvatarPathScRsp addBasicTypeIdList(final int value) {
      bitField0_ |= 0x00000008;
      basicTypeIdList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 basic_type_id_list = 8;</code>
     * @param values the basicTypeIdList to add
     * @return this
     */
    public UnlockAvatarPathScRsp addAllBasicTypeIdList(final int... values) {
      bitField0_ |= 0x00000008;
      basicTypeIdList.addAll(values);
      return this;
    }

    @Override
    public UnlockAvatarPathScRsp copyFrom(final UnlockAvatarPathScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        avatarId = other.avatarId;
        rewardList.copyFrom(other.rewardList);
        basicTypeIdList.copyFrom(other.basicTypeIdList);
      }
      return this;
    }

    @Override
    public UnlockAvatarPathScRsp mergeFrom(final UnlockAvatarPathScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasAvatarId()) {
        setAvatarIdValue(other.avatarId);
      }
      if (other.hasRewardList()) {
        getMutableRewardList().mergeFrom(other.rewardList);
      }
      if (other.hasBasicTypeIdList()) {
        getMutableBasicTypeIdList().addAll(other.basicTypeIdList);
      }
      return this;
    }

    @Override
    public UnlockAvatarPathScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      avatarId = 0;
      rewardList.clear();
      basicTypeIdList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof UnlockAvatarPathScRsp)) {
        return false;
      }
      UnlockAvatarPathScRsp other = (UnlockAvatarPathScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasAvatarId() || avatarId == other.avatarId)
        && (!hasRewardList() || rewardList.equals(other.rewardList))
        && (!hasBasicTypeIdList() || basicTypeIdList.equals(other.basicTypeIdList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeEnumNoTag(avatarId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 74);
        output.writeMessageNoTag(rewardList);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < basicTypeIdList.length(); i++) {
          output.writeRawByte((byte) 64);
          output.writeUInt32NoTag(basicTypeIdList.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(avatarId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(rewardList);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * basicTypeIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(basicTypeIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public UnlockAvatarPathScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 96: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // avatarId
            final int value = input.readInt32();
            if (MultiPathAvatarTypeOuterClass.MultiPathAvatarType.forNumber(value) != null) {
              avatarId = value;
              bitField0_ |= 0x00000002;
            }
            tag = input.readTag();
            if (tag != 74) {
              break;
            }
          }
          case 74: {
            // rewardList
            input.readMessage(rewardList);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 66) {
              break;
            }
          }
          case 66: {
            // basicTypeIdList [packed=true]
            input.readPackedUInt32(basicTypeIdList, 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 64: {
            // basicTypeIdList [packed=false]
            tag = input.readRepeatedUInt32(basicTypeIdList, 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.avatarId, avatarId, MultiPathAvatarTypeOuterClass.MultiPathAvatarType.converter());
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.rewardList, rewardList);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedUInt32(FieldNames.basicTypeIdList, basicTypeIdList);
      }
      output.endObject();
    }

    @Override
    public UnlockAvatarPathScRsp 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 1787287636:
          case -428636735: {
            if (input.isAtField(FieldNames.avatarId)) {
              if (!input.trySkipNullValue()) {
                final MultiPathAvatarTypeOuterClass.MultiPathAvatarType value = input.readEnum(MultiPathAvatarTypeOuterClass.MultiPathAvatarType.converter());
                if (value != null) {
                  avatarId = value.getNumber();
                  bitField0_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1690977389:
          case 898318254: {
            if (input.isAtField(FieldNames.rewardList)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(rewardList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -332160255:
          case 99090862: {
            if (input.isAtField(FieldNames.basicTypeIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(basicTypeIdList);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum UnlockAvatarPathScRspFactory implements MessageFactory<UnlockAvatarPathScRsp> {
      INSTANCE;

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

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

      static final FieldName avatarId = FieldName.forField("avatarId", "avatar_id");

      static final FieldName rewardList = FieldName.forField("rewardList", "reward_list");

      static final FieldName basicTypeIdList = FieldName.forField("basicTypeIdList", "basic_type_id_list");
    }
  }
}
