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

    /**
     * <code>optional uint32 battle_record_stars = 6;</code>
     */
    private int battleRecordStars;

    /**
     * <code>optional uint32 round_count = 8;</code>
     */
    private int roundCount;

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

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 11;</code>
     */
    private final RepeatedMessage<BattleRecordAvatarsOuterClass.BattleRecordAvatars> battleRecordAvatars = RepeatedMessage.newEmptyInstance(BattleRecordAvatarsOuterClass.BattleRecordAvatars.getFactory());

    private BattleRecord1Info() {
    }

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

    /**
     * <code>optional uint32 battle_record_stars = 6;</code>
     * @return whether the battleRecordStars field is set
     */
    public boolean hasBattleRecordStars() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 battle_record_stars = 6;</code>
     * @return this
     */
    public BattleRecord1Info clearBattleRecordStars() {
      bitField0_ &= ~0x00000001;
      battleRecordStars = 0;
      return this;
    }

    /**
     * <code>optional uint32 battle_record_stars = 6;</code>
     * @return the battleRecordStars
     */
    public int getBattleRecordStars() {
      return battleRecordStars;
    }

    /**
     * <code>optional uint32 battle_record_stars = 6;</code>
     * @param value the battleRecordStars to set
     * @return this
     */
    public BattleRecord1Info setBattleRecordStars(final int value) {
      bitField0_ |= 0x00000001;
      battleRecordStars = value;
      return this;
    }

    /**
     * <code>optional uint32 round_count = 8;</code>
     * @return whether the roundCount field is set
     */
    public boolean hasRoundCount() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 round_count = 8;</code>
     * @return this
     */
    public BattleRecord1Info clearRoundCount() {
      bitField0_ &= ~0x00000002;
      roundCount = 0;
      return this;
    }

    /**
     * <code>optional uint32 round_count = 8;</code>
     * @return the roundCount
     */
    public int getRoundCount() {
      return roundCount;
    }

    /**
     * <code>optional uint32 round_count = 8;</code>
     * @param value the roundCount to set
     * @return this
     */
    public BattleRecord1Info setRoundCount(final int value) {
      bitField0_ |= 0x00000002;
      roundCount = value;
      return this;
    }

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

    /**
     * <code>optional uint32 level = 12;</code>
     * @return this
     */
    public BattleRecord1Info clearLevel() {
      bitField0_ &= ~0x00000004;
      level = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 level = 12;</code>
     * @param value the level to set
     * @return this
     */
    public BattleRecord1Info setLevel(final int value) {
      bitField0_ |= 0x00000004;
      level = value;
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 11;</code>
     * @return whether the battleRecordAvatars field is set
     */
    public boolean hasBattleRecordAvatars() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 11;</code>
     * @return this
     */
    public BattleRecord1Info clearBattleRecordAvatars() {
      bitField0_ &= ~0x00000008;
      battleRecordAvatars.clear();
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 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 #getMutableBattleRecordAvatars()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<BattleRecordAvatarsOuterClass.BattleRecordAvatars> getBattleRecordAvatars(
        ) {
      return battleRecordAvatars;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 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<BattleRecordAvatarsOuterClass.BattleRecordAvatars> getMutableBattleRecordAvatars(
        ) {
      bitField0_ |= 0x00000008;
      return battleRecordAvatars;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 11;</code>
     * @param value the battleRecordAvatars to add
     * @return this
     */
    public BattleRecord1Info addBattleRecordAvatars(
        final BattleRecordAvatarsOuterClass.BattleRecordAvatars value) {
      bitField0_ |= 0x00000008;
      battleRecordAvatars.add(value);
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 11;</code>
     * @param values the battleRecordAvatars to add
     * @return this
     */
    public BattleRecord1Info addAllBattleRecordAvatars(
        final BattleRecordAvatarsOuterClass.BattleRecordAvatars... values) {
      bitField0_ |= 0x00000008;
      battleRecordAvatars.addAll(values);
      return this;
    }

    @Override
    public BattleRecord1Info copyFrom(final BattleRecord1Info other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        battleRecordStars = other.battleRecordStars;
        roundCount = other.roundCount;
        level = other.level;
        battleRecordAvatars.copyFrom(other.battleRecordAvatars);
      }
      return this;
    }

    @Override
    public BattleRecord1Info mergeFrom(final BattleRecord1Info other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasBattleRecordStars()) {
        setBattleRecordStars(other.battleRecordStars);
      }
      if (other.hasRoundCount()) {
        setRoundCount(other.roundCount);
      }
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasBattleRecordAvatars()) {
        getMutableBattleRecordAvatars().addAll(other.battleRecordAvatars);
      }
      return this;
    }

    @Override
    public BattleRecord1Info clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      battleRecordStars = 0;
      roundCount = 0;
      level = 0;
      battleRecordAvatars.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof BattleRecord1Info)) {
        return false;
      }
      BattleRecord1Info other = (BattleRecord1Info) o;
      return bitField0_ == other.bitField0_
        && (!hasBattleRecordStars() || battleRecordStars == other.battleRecordStars)
        && (!hasRoundCount() || roundCount == other.roundCount)
        && (!hasLevel() || level == other.level)
        && (!hasBattleRecordAvatars() || battleRecordAvatars.equals(other.battleRecordAvatars));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(battleRecordStars);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(roundCount);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(level);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < battleRecordAvatars.length(); i++) {
          output.writeRawByte((byte) 90);
          output.writeMessageNoTag(battleRecordAvatars.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(battleRecordStars);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(roundCount);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(level);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * battleRecordAvatars.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(battleRecordAvatars);
      }
      return size;
    }

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

    @Override
    public BattleRecord1Info mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1025792328:
          case 59201306: {
            if (input.isAtField(FieldNames.battleRecordStars)) {
              if (!input.trySkipNullValue()) {
                battleRecordStars = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -171935711:
          case -244677858: {
            if (input.isAtField(FieldNames.roundCount)) {
              if (!input.trySkipNullValue()) {
                roundCount = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -976809263:
          case -1974979917: {
            if (input.isAtField(FieldNames.battleRecordAvatars)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(battleRecordAvatars);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleRecord1InfoFactory implements MessageFactory<BattleRecord1Info> {
      INSTANCE;

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

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

      static final FieldName roundCount = FieldName.forField("roundCount", "round_count");

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

      static final FieldName battleRecordAvatars = FieldName.forField("battleRecordAvatars", "battle_record_avatars");
    }
  }
}
