// Code generated by protocol buffer compiler. Do not edit!
package emu.nebula.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.RepeatedByte;
import us.hebi.quickbuf.RepeatedInt;
import us.hebi.quickbuf.RepeatedMessage;

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

    /**
     * <code>optional uint32 ControlId = 1;</code>
     */
    private int controlId;

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

    /**
     * <code>optional uint32 Star = 3;</code>
     */
    private int star;

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    /**
     * <code>repeated uint32 StarRewards = 101;</code>
     */
    private final RepeatedInt starRewards = RepeatedInt.newEmptyInstance();

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</code>
     */
    private final RepeatedMessage<Public.ScoreBossLevel> levels = RepeatedMessage.newEmptyInstance(Public.ScoreBossLevel.getFactory());

    private ScoreBossInfo() {
    }

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

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

    /**
     * <code>optional uint32 ControlId = 1;</code>
     * @return this
     */
    public ScoreBossInfo clearControlId() {
      bitField0_ &= ~0x00000001;
      controlId = 0;
      return this;
    }

    /**
     * <code>optional uint32 ControlId = 1;</code>
     * @return the controlId
     */
    public int getControlId() {
      return controlId;
    }

    /**
     * <code>optional uint32 ControlId = 1;</code>
     * @param value the controlId to set
     * @return this
     */
    public ScoreBossInfo setControlId(final int value) {
      bitField0_ |= 0x00000001;
      controlId = value;
      return this;
    }

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

    /**
     * <code>optional uint32 Score = 2;</code>
     * @return this
     */
    public ScoreBossInfo clearScore() {
      bitField0_ &= ~0x00000002;
      score = 0;
      return this;
    }

    /**
     * <code>optional uint32 Score = 2;</code>
     * @return the score
     */
    public int getScore() {
      return score;
    }

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

    /**
     * <code>optional uint32 Star = 3;</code>
     * @return whether the star field is set
     */
    public boolean hasStar() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 Star = 3;</code>
     * @return this
     */
    public ScoreBossInfo clearStar() {
      bitField0_ &= ~0x00000004;
      star = 0;
      return this;
    }

    /**
     * <code>optional uint32 Star = 3;</code>
     * @return the star
     */
    public int getStar() {
      return star;
    }

    /**
     * <code>optional uint32 Star = 3;</code>
     * @param value the star to set
     * @return this
     */
    public ScoreBossInfo setStar(final int value) {
      bitField0_ |= 0x00000004;
      star = value;
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ScoreBossInfo clearNextPackage() {
      bitField0_ &= ~0x00000008;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</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 RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000008;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public ScoreBossInfo addNextPackage(final byte value) {
      bitField0_ |= 0x00000008;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public ScoreBossInfo addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public ScoreBossInfo setNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.copyFrom(values);
      return this;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</code>
     * @return whether the starRewards field is set
     */
    public boolean hasStarRewards() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</code>
     * @return this
     */
    public ScoreBossInfo clearStarRewards() {
      bitField0_ &= ~0x00000010;
      starRewards.clear();
      return this;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</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 #getMutableStarRewards()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getStarRewards() {
      return starRewards;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</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 getMutableStarRewards() {
      bitField0_ |= 0x00000010;
      return starRewards;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</code>
     * @param value the starRewards to add
     * @return this
     */
    public ScoreBossInfo addStarRewards(final int value) {
      bitField0_ |= 0x00000010;
      starRewards.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 StarRewards = 101;</code>
     * @param values the starRewards to add
     * @return this
     */
    public ScoreBossInfo addAllStarRewards(final int... values) {
      bitField0_ |= 0x00000010;
      starRewards.addAll(values);
      return this;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</code>
     * @return whether the levels field is set
     */
    public boolean hasLevels() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</code>
     * @return this
     */
    public ScoreBossInfo clearLevels() {
      bitField0_ &= ~0x00000020;
      levels.clear();
      return this;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</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 #getMutableLevels()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<Public.ScoreBossLevel> getLevels() {
      return levels;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</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<Public.ScoreBossLevel> getMutableLevels() {
      bitField0_ |= 0x00000020;
      return levels;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</code>
     * @param value the levels to add
     * @return this
     */
    public ScoreBossInfo addLevels(final Public.ScoreBossLevel value) {
      bitField0_ |= 0x00000020;
      levels.add(value);
      return this;
    }

    /**
     * <code>repeated .ScoreBossLevel Levels = 102;</code>
     * @param values the levels to add
     * @return this
     */
    public ScoreBossInfo addAllLevels(final Public.ScoreBossLevel... values) {
      bitField0_ |= 0x00000020;
      levels.addAll(values);
      return this;
    }

    @Override
    public ScoreBossInfo copyFrom(final ScoreBossInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        controlId = other.controlId;
        score = other.score;
        star = other.star;
        nextPackage.copyFrom(other.nextPackage);
        starRewards.copyFrom(other.starRewards);
        levels.copyFrom(other.levels);
      }
      return this;
    }

    @Override
    public ScoreBossInfo mergeFrom(final ScoreBossInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasControlId()) {
        setControlId(other.controlId);
      }
      if (other.hasScore()) {
        setScore(other.score);
      }
      if (other.hasStar()) {
        setStar(other.star);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasStarRewards()) {
        getMutableStarRewards().addAll(other.starRewards);
      }
      if (other.hasLevels()) {
        getMutableLevels().addAll(other.levels);
      }
      return this;
    }

    @Override
    public ScoreBossInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      controlId = 0;
      score = 0;
      star = 0;
      nextPackage.clear();
      starRewards.clear();
      levels.clear();
      return this;
    }

    @Override
    public ScoreBossInfo clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      nextPackage.clear();
      starRewards.clear();
      levels.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ScoreBossInfo)) {
        return false;
      }
      ScoreBossInfo other = (ScoreBossInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasControlId() || controlId == other.controlId)
        && (!hasScore() || score == other.score)
        && (!hasStar() || star == other.star)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasStarRewards() || starRewards.equals(other.starRewards))
        && (!hasLevels() || levels.equals(other.levels));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(controlId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(star);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        for (int i = 0; i < starRewards.length(); i++) {
          output.writeRawLittleEndian16((short) 1704);
          output.writeUInt32NoTag(starRewards.array()[i]);
        }
      }
      if ((bitField0_ & 0x00000020) != 0) {
        for (int i = 0; i < levels.length(); i++) {
          output.writeRawLittleEndian16((short) 1714);
          output.writeMessageNoTag(levels.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(controlId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(star);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += (2 * starRewards.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(starRewards);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += (2 * levels.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(levels);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ScoreBossInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // controlId
            controlId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // score
            score = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // star
            star = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 810) {
              break;
            }
          }
          case 810: {
            // starRewards [packed=true]
            input.readPackedUInt32(starRewards, tag);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 818) {
              break;
            }
          }
          case 818: {
            // levels
            tag = input.readRepeatedMessage(levels, tag);
            bitField0_ |= 0x00000020;
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 808: {
            // starRewards [packed=false]
            tag = input.readRepeatedUInt32(starRewards, tag);
            bitField0_ |= 0x00000010;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.controlId, controlId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.score, score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.star, star);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRepeatedUInt32(FieldNames.starRewards, starRewards);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRepeatedMessage(FieldNames.levels, levels);
      }
      output.endObject();
    }

    @Override
    public ScoreBossInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1608887096: {
            if (input.isAtField(FieldNames.controlId)) {
              if (!input.trySkipNullValue()) {
                controlId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 79711858: {
            if (input.isAtField(FieldNames.score)) {
              if (!input.trySkipNullValue()) {
                score = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2587250: {
            if (input.isAtField(FieldNames.star)) {
              if (!input.trySkipNullValue()) {
                star = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 208957522: {
            if (input.isAtField(FieldNames.starRewards)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(starRewards);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2022260337: {
            if (input.isAtField(FieldNames.levels)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(levels);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ScoreBossInfoFactory implements MessageFactory<ScoreBossInfo> {
      INSTANCE;

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

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

      static final FieldName score = FieldName.forField("Score");

      static final FieldName star = FieldName.forField("Star");

      static final FieldName nextPackage = FieldName.forField("NextPackage");

      static final FieldName starRewards = FieldName.forField("StarRewards");

      static final FieldName levels = FieldName.forField("Levels");
    }
  }
}
