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

    /**
     * <code>optional uint32 challenge_peak_group_id = 8;</code>
     */
    private int challengePeakGroupId;

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</code>
     */
    private final RepeatedMessage<ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo> lineupList = RepeatedMessage.newEmptyInstance(ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo.getFactory());

    private SetChallengePeakMobLineupAvatarCsReq() {
    }

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

    /**
     * <code>optional uint32 challenge_peak_group_id = 8;</code>
     * @return whether the challengePeakGroupId field is set
     */
    public boolean hasChallengePeakGroupId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 challenge_peak_group_id = 8;</code>
     * @return this
     */
    public SetChallengePeakMobLineupAvatarCsReq clearChallengePeakGroupId() {
      bitField0_ &= ~0x00000001;
      challengePeakGroupId = 0;
      return this;
    }

    /**
     * <code>optional uint32 challenge_peak_group_id = 8;</code>
     * @return the challengePeakGroupId
     */
    public int getChallengePeakGroupId() {
      return challengePeakGroupId;
    }

    /**
     * <code>optional uint32 challenge_peak_group_id = 8;</code>
     * @param value the challengePeakGroupId to set
     * @return this
     */
    public SetChallengePeakMobLineupAvatarCsReq setChallengePeakGroupId(final int value) {
      bitField0_ |= 0x00000001;
      challengePeakGroupId = value;
      return this;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</code>
     * @return whether the lineupList field is set
     */
    public boolean hasLineupList() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</code>
     * @return this
     */
    public SetChallengePeakMobLineupAvatarCsReq clearLineupList() {
      bitField0_ &= ~0x00000002;
      lineupList.clear();
      return this;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</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 #getMutableLineupList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo> getLineupList(
        ) {
      return lineupList;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</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<ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo> getMutableLineupList(
        ) {
      bitField0_ |= 0x00000002;
      return lineupList;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</code>
     * @param value the lineupList to add
     * @return this
     */
    public SetChallengePeakMobLineupAvatarCsReq addLineupList(
        final ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo value) {
      bitField0_ |= 0x00000002;
      lineupList.add(value);
      return this;
    }

    /**
     * <code>repeated .ChallengePeakMobLineupInfo lineup_list = 2;</code>
     * @param values the lineupList to add
     * @return this
     */
    public SetChallengePeakMobLineupAvatarCsReq addAllLineupList(
        final ChallengePeakMobLineupInfoOuterClass.ChallengePeakMobLineupInfo... values) {
      bitField0_ |= 0x00000002;
      lineupList.addAll(values);
      return this;
    }

    @Override
    public SetChallengePeakMobLineupAvatarCsReq copyFrom(
        final SetChallengePeakMobLineupAvatarCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        challengePeakGroupId = other.challengePeakGroupId;
        lineupList.copyFrom(other.lineupList);
      }
      return this;
    }

    @Override
    public SetChallengePeakMobLineupAvatarCsReq mergeFrom(
        final SetChallengePeakMobLineupAvatarCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasChallengePeakGroupId()) {
        setChallengePeakGroupId(other.challengePeakGroupId);
      }
      if (other.hasLineupList()) {
        getMutableLineupList().addAll(other.lineupList);
      }
      return this;
    }

    @Override
    public SetChallengePeakMobLineupAvatarCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      challengePeakGroupId = 0;
      lineupList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof SetChallengePeakMobLineupAvatarCsReq)) {
        return false;
      }
      SetChallengePeakMobLineupAvatarCsReq other = (SetChallengePeakMobLineupAvatarCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasChallengePeakGroupId() || challengePeakGroupId == other.challengePeakGroupId)
        && (!hasLineupList() || lineupList.equals(other.lineupList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(challengePeakGroupId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < lineupList.length(); i++) {
          output.writeRawByte((byte) 18);
          output.writeMessageNoTag(lineupList.get(i));
        }
      }
    }

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

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

    @Override
    public SetChallengePeakMobLineupAvatarCsReq mergeFrom(final JsonSource input) throws
        IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1143355832:
          case -502257825: {
            if (input.isAtField(FieldNames.challengePeakGroupId)) {
              if (!input.trySkipNullValue()) {
                challengePeakGroupId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 781801165:
          case -1516340914: {
            if (input.isAtField(FieldNames.lineupList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(lineupList);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SetChallengePeakMobLineupAvatarCsReqFactory implements MessageFactory<SetChallengePeakMobLineupAvatarCsReq> {
      INSTANCE;

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

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

      static final FieldName lineupList = FieldName.forField("lineupList", "lineup_list");
    }
  }
}
