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

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

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

    /**
     * <code>optional uint32 group_id = 14;</code>
     */
    private int groupId;

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</code>
     */
    private final BattleRecord1OuterClass.BattleRecord1 record1 = BattleRecord1OuterClass.BattleRecord1.newInstance();

    private GetChallengeGroupStatisticsScRsp() {
    }

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

    public boolean hasStatistics() {
      return (((bitField0_ & 0x00000001)) != 0);
    }

    public GetChallengeGroupStatisticsScRsp clearStatistics() {
      if (hasStatistics()) {
        clearRecord1();
      }
      return this;
    }

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

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

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

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

    /**
     * <code>optional uint32 group_id = 14;</code>
     * @return whether the groupId field is set
     */
    public boolean hasGroupId() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 group_id = 14;</code>
     * @return this
     */
    public GetChallengeGroupStatisticsScRsp clearGroupId() {
      bitField0_ &= ~0x00000004;
      groupId = 0;
      return this;
    }

    /**
     * <code>optional uint32 group_id = 14;</code>
     * @return the groupId
     */
    public int getGroupId() {
      return groupId;
    }

    /**
     * <code>optional uint32 group_id = 14;</code>
     * @param value the groupId to set
     * @return this
     */
    public GetChallengeGroupStatisticsScRsp setGroupId(final int value) {
      bitField0_ |= 0x00000004;
      groupId = value;
      return this;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</code>
     * @return whether the record1 field is set
     */
    public boolean hasRecord1() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</code>
     * @return this
     */
    public GetChallengeGroupStatisticsScRsp clearRecord1() {
      bitField0_ &= ~0x00000001;
      record1.clear();
      return this;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</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 #getMutableRecord1()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public BattleRecord1OuterClass.BattleRecord1 getRecord1() {
      return record1;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</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 BattleRecord1OuterClass.BattleRecord1 getMutableRecord1() {
      bitField0_ |= 0x00000001;
      return record1;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 10;
     *  BattleRecord3 record3 = 7; // type 3, either the new rogue or the new challenge
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 13;</code>
     * @param value the record1 to set
     * @return this
     */
    public GetChallengeGroupStatisticsScRsp setRecord1(
        final BattleRecord1OuterClass.BattleRecord1 value) {
      bitField0_ |= 0x00000001;
      record1.copyFrom(value);
      return this;
    }

    @Override
    public GetChallengeGroupStatisticsScRsp copyFrom(final GetChallengeGroupStatisticsScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        groupId = other.groupId;
        record1.copyFrom(other.record1);
      }
      return this;
    }

    @Override
    public GetChallengeGroupStatisticsScRsp mergeFrom(
        final GetChallengeGroupStatisticsScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasGroupId()) {
        setGroupId(other.groupId);
      }
      if (other.hasRecord1()) {
        getMutableRecord1().mergeFrom(other.record1);
      }
      return this;
    }

    @Override
    public GetChallengeGroupStatisticsScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      groupId = 0;
      record1.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetChallengeGroupStatisticsScRsp)) {
        return false;
      }
      GetChallengeGroupStatisticsScRsp other = (GetChallengeGroupStatisticsScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasGroupId() || groupId == other.groupId)
        && (!hasRecord1() || record1.equals(other.record1));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 106);
        output.writeMessageNoTag(record1);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(record1);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetChallengeGroupStatisticsScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // groupId
            groupId = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 106) {
              break;
            }
          }
          case 106: {
            // record1
            input.readMessage(record1);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            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_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.groupId, groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeMessage(FieldNames.record1, record1);
      }
      output.endObject();
    }

    @Override
    public GetChallengeGroupStatisticsScRsp 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_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 293428218:
          case 506361563: {
            if (input.isAtField(FieldNames.groupId)) {
              if (!input.trySkipNullValue()) {
                groupId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1082596864: {
            if (input.isAtField(FieldNames.record1)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(record1);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetChallengeGroupStatisticsScRspFactory implements MessageFactory<GetChallengeGroupStatisticsScRsp> {
      INSTANCE;

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

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

      static final FieldName groupId = FieldName.forField("groupId", "group_id");

      static final FieldName record1 = FieldName.forField("record1");
    }
  }
}
