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

    /**
     * <code>optional uint32 cur_pet_id = 1;</code>
     */
    private int curPetId;

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

    /**
     * <code>repeated uint32 pet_id_list = 6;</code>
     */
    private final RepeatedInt petIdList = RepeatedInt.newEmptyInstance();

    private GetPetDataScRsp() {
    }

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

    /**
     * <code>optional uint32 cur_pet_id = 1;</code>
     * @return whether the curPetId field is set
     */
    public boolean hasCurPetId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 cur_pet_id = 1;</code>
     * @return this
     */
    public GetPetDataScRsp clearCurPetId() {
      bitField0_ &= ~0x00000001;
      curPetId = 0;
      return this;
    }

    /**
     * <code>optional uint32 cur_pet_id = 1;</code>
     * @return the curPetId
     */
    public int getCurPetId() {
      return curPetId;
    }

    /**
     * <code>optional uint32 cur_pet_id = 1;</code>
     * @param value the curPetId to set
     * @return this
     */
    public GetPetDataScRsp setCurPetId(final int value) {
      bitField0_ |= 0x00000001;
      curPetId = value;
      return this;
    }

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

    /**
     * <code>optional uint32 retcode = 11;</code>
     * @return this
     */
    public GetPetDataScRsp clearRetcode() {
      bitField0_ &= ~0x00000002;
      retcode = 0;
      return this;
    }

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

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

    /**
     * <code>repeated uint32 pet_id_list = 6;</code>
     * @return whether the petIdList field is set
     */
    public boolean hasPetIdList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated uint32 pet_id_list = 6;</code>
     * @return this
     */
    public GetPetDataScRsp clearPetIdList() {
      bitField0_ &= ~0x00000004;
      petIdList.clear();
      return this;
    }

    /**
     * <code>repeated uint32 pet_id_list = 6;</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 #getMutablePetIdList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getPetIdList() {
      return petIdList;
    }

    /**
     * <code>repeated uint32 pet_id_list = 6;</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 getMutablePetIdList() {
      bitField0_ |= 0x00000004;
      return petIdList;
    }

    /**
     * <code>repeated uint32 pet_id_list = 6;</code>
     * @param value the petIdList to add
     * @return this
     */
    public GetPetDataScRsp addPetIdList(final int value) {
      bitField0_ |= 0x00000004;
      petIdList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 pet_id_list = 6;</code>
     * @param values the petIdList to add
     * @return this
     */
    public GetPetDataScRsp addAllPetIdList(final int... values) {
      bitField0_ |= 0x00000004;
      petIdList.addAll(values);
      return this;
    }

    @Override
    public GetPetDataScRsp copyFrom(final GetPetDataScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        curPetId = other.curPetId;
        retcode = other.retcode;
        petIdList.copyFrom(other.petIdList);
      }
      return this;
    }

    @Override
    public GetPetDataScRsp mergeFrom(final GetPetDataScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasCurPetId()) {
        setCurPetId(other.curPetId);
      }
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasPetIdList()) {
        getMutablePetIdList().addAll(other.petIdList);
      }
      return this;
    }

    @Override
    public GetPetDataScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      curPetId = 0;
      retcode = 0;
      petIdList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetPetDataScRsp)) {
        return false;
      }
      GetPetDataScRsp other = (GetPetDataScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasCurPetId() || curPetId == other.curPetId)
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasPetIdList() || petIdList.equals(other.petIdList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(curPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 88);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < petIdList.length(); i++) {
          output.writeRawByte((byte) 48);
          output.writeUInt32NoTag(petIdList.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(curPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * petIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(petIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetPetDataScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // curPetId
            curPetId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 88) {
              break;
            }
          }
          case 88: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // petIdList [packed=true]
            input.readPackedUInt32(petIdList, tag);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 48: {
            // petIdList [packed=false]
            tag = input.readRepeatedUInt32(petIdList, tag);
            bitField0_ |= 0x00000004;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.curPetId, curPetId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedUInt32(FieldNames.petIdList, petIdList);
      }
      output.endObject();
    }

    @Override
    public GetPetDataScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 544007226:
          case -465065190: {
            if (input.isAtField(FieldNames.curPetId)) {
              if (!input.trySkipNullValue()) {
                curPetId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1414608472:
          case -1558569438: {
            if (input.isAtField(FieldNames.petIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(petIdList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetPetDataScRspFactory implements MessageFactory<GetPetDataScRsp> {
      INSTANCE;

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

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

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

      static final FieldName petIdList = FieldName.forField("petIdList", "pet_id_list");
    }
  }
}
