// 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.RepeatedMessage;

public final class GetChallengePeakDataScRspOuterClass {
  /**
   * Protobuf type {@code GetChallengePeakDataScRsp}
   */
  public static final class GetChallengePeakDataScRsp extends ProtoMessage<GetChallengePeakDataScRsp> implements Cloneable {
    private static final long serialVersionUID = 0L;

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

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

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</code>
     */
    private final RepeatedMessage<ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo> challengePeakList = RepeatedMessage.newEmptyInstance(ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo.getFactory());

    private GetChallengePeakDataScRsp() {
    }

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

    /**
     * <code>optional uint32 cur_challenge_peak_group_id = 4;</code>
     * @return whether the curChallengePeakGroupId field is set
     */
    public boolean hasCurChallengePeakGroupId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 cur_challenge_peak_group_id = 4;</code>
     * @return this
     */
    public GetChallengePeakDataScRsp clearCurChallengePeakGroupId() {
      bitField0_ &= ~0x00000001;
      curChallengePeakGroupId = 0;
      return this;
    }

    /**
     * <code>optional uint32 cur_challenge_peak_group_id = 4;</code>
     * @return the curChallengePeakGroupId
     */
    public int getCurChallengePeakGroupId() {
      return curChallengePeakGroupId;
    }

    /**
     * <code>optional uint32 cur_challenge_peak_group_id = 4;</code>
     * @param value the curChallengePeakGroupId to set
     * @return this
     */
    public GetChallengePeakDataScRsp setCurChallengePeakGroupId(final int value) {
      bitField0_ |= 0x00000001;
      curChallengePeakGroupId = value;
      return this;
    }

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

    /**
     * <code>optional uint32 retcode = 12;</code>
     * @return this
     */
    public GetChallengePeakDataScRsp clearRetcode() {
      bitField0_ &= ~0x00000002;
      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 GetChallengePeakDataScRsp setRetcode(final int value) {
      bitField0_ |= 0x00000002;
      retcode = value;
      return this;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</code>
     * @return whether the challengePeakList field is set
     */
    public boolean hasChallengePeakList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</code>
     * @return this
     */
    public GetChallengePeakDataScRsp clearChallengePeakList() {
      bitField0_ &= ~0x00000004;
      challengePeakList.clear();
      return this;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</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 #getMutableChallengePeakList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo> getChallengePeakList(
        ) {
      return challengePeakList;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</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 RepeatedMessage<ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo> getMutableChallengePeakList(
        ) {
      bitField0_ |= 0x00000004;
      return challengePeakList;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</code>
     * @param value the challengePeakList to add
     * @return this
     */
    public GetChallengePeakDataScRsp addChallengePeakList(
        final ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo value) {
      bitField0_ |= 0x00000004;
      challengePeakList.add(value);
      return this;
    }

    /**
     * <code>repeated .ChallengePeakGroupInfo challenge_peak_list = 11;</code>
     * @param values the challengePeakList to add
     * @return this
     */
    public GetChallengePeakDataScRsp addAllChallengePeakList(
        final ChallengePeakGroupInfoOuterClass.ChallengePeakGroupInfo... values) {
      bitField0_ |= 0x00000004;
      challengePeakList.addAll(values);
      return this;
    }

    @Override
    public GetChallengePeakDataScRsp copyFrom(final GetChallengePeakDataScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        curChallengePeakGroupId = other.curChallengePeakGroupId;
        retcode = other.retcode;
        challengePeakList.copyFrom(other.challengePeakList);
      }
      return this;
    }

    @Override
    public GetChallengePeakDataScRsp mergeFrom(final GetChallengePeakDataScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasCurChallengePeakGroupId()) {
        setCurChallengePeakGroupId(other.curChallengePeakGroupId);
      }
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasChallengePeakList()) {
        getMutableChallengePeakList().addAll(other.challengePeakList);
      }
      return this;
    }

    @Override
    public GetChallengePeakDataScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      curChallengePeakGroupId = 0;
      retcode = 0;
      challengePeakList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetChallengePeakDataScRsp)) {
        return false;
      }
      GetChallengePeakDataScRsp other = (GetChallengePeakDataScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasCurChallengePeakGroupId() || curChallengePeakGroupId == other.curChallengePeakGroupId)
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasChallengePeakList() || challengePeakList.equals(other.challengePeakList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(curChallengePeakGroupId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < challengePeakList.length(); i++) {
          output.writeRawByte((byte) 90);
          output.writeMessageNoTag(challengePeakList.get(i));
        }
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public GetChallengePeakDataScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 32: {
            // curChallengePeakGroupId
            curChallengePeakGroupId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 96) {
              break;
            }
          }
          case 96: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 90) {
              break;
            }
          }
          case 90: {
            // challengePeakList
            tag = input.readRepeatedMessage(challengePeakList, tag);
            bitField0_ |= 0x00000004;
            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.curChallengePeakGroupId, curChallengePeakGroupId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.challengePeakList, challengePeakList);
      }
      output.endObject();
    }

    @Override
    public GetChallengePeakDataScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 408244248:
          case 1188228704: {
            if (input.isAtField(FieldNames.curChallengePeakGroupId)) {
              if (!input.trySkipNullValue()) {
                curChallengePeakGroupId = 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 -1768498272:
          case -1100397790: {
            if (input.isAtField(FieldNames.challengePeakList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(challengePeakList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetChallengePeakDataScRspFactory implements MessageFactory<GetChallengePeakDataScRsp> {
      INSTANCE;

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

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

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

      static final FieldName challengePeakList = FieldName.forField("challengePeakList", "challenge_peak_list");
    }
  }
}
