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

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

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

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

    /**
     * <code>optional uint32 DamageScore = 4;</code>
     */
    private int damageScore;

    /**
     * <code>optional uint32 SkillScore = 5;</code>
     */
    private int skillScore;

    /**
     * <code>optional uint32 BossResultLevel = 6;</code>
     */
    private int bossResultLevel;

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     */
    private final TravelerDuelRankUpload.TravelerDuelBattleSamples sample = TravelerDuelRankUpload.TravelerDuelBattleSamples.newInstance();

    /**
     * <code>optional .Events Events = 15;</code>
     */
    private final Public.Events events = Public.Events.newInstance();

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

    private ScoreBossSettleReq() {
    }

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

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

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

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

    /**
     * <code>optional uint32 Star = 1;</code>
     * @param value the star to set
     * @return this
     */
    public ScoreBossSettleReq setStar(final int value) {
      bitField0_ |= 0x00000001;
      star = 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 ScoreBossSettleReq 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 ScoreBossSettleReq setScore(final int value) {
      bitField0_ |= 0x00000002;
      score = value;
      return this;
    }

    /**
     * <code>optional uint32 DamageScore = 4;</code>
     * @return whether the damageScore field is set
     */
    public boolean hasDamageScore() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 DamageScore = 4;</code>
     * @return this
     */
    public ScoreBossSettleReq clearDamageScore() {
      bitField0_ &= ~0x00000004;
      damageScore = 0;
      return this;
    }

    /**
     * <code>optional uint32 DamageScore = 4;</code>
     * @return the damageScore
     */
    public int getDamageScore() {
      return damageScore;
    }

    /**
     * <code>optional uint32 DamageScore = 4;</code>
     * @param value the damageScore to set
     * @return this
     */
    public ScoreBossSettleReq setDamageScore(final int value) {
      bitField0_ |= 0x00000004;
      damageScore = value;
      return this;
    }

    /**
     * <code>optional uint32 SkillScore = 5;</code>
     * @return whether the skillScore field is set
     */
    public boolean hasSkillScore() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 SkillScore = 5;</code>
     * @return this
     */
    public ScoreBossSettleReq clearSkillScore() {
      bitField0_ &= ~0x00000008;
      skillScore = 0;
      return this;
    }

    /**
     * <code>optional uint32 SkillScore = 5;</code>
     * @return the skillScore
     */
    public int getSkillScore() {
      return skillScore;
    }

    /**
     * <code>optional uint32 SkillScore = 5;</code>
     * @param value the skillScore to set
     * @return this
     */
    public ScoreBossSettleReq setSkillScore(final int value) {
      bitField0_ |= 0x00000008;
      skillScore = value;
      return this;
    }

    /**
     * <code>optional uint32 BossResultLevel = 6;</code>
     * @return whether the bossResultLevel field is set
     */
    public boolean hasBossResultLevel() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional uint32 BossResultLevel = 6;</code>
     * @return this
     */
    public ScoreBossSettleReq clearBossResultLevel() {
      bitField0_ &= ~0x00000010;
      bossResultLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 BossResultLevel = 6;</code>
     * @return the bossResultLevel
     */
    public int getBossResultLevel() {
      return bossResultLevel;
    }

    /**
     * <code>optional uint32 BossResultLevel = 6;</code>
     * @param value the bossResultLevel to set
     * @return this
     */
    public ScoreBossSettleReq setBossResultLevel(final int value) {
      bitField0_ |= 0x00000010;
      bossResultLevel = value;
      return this;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @return whether the sample field is set
     */
    public boolean hasSample() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @return this
     */
    public ScoreBossSettleReq clearSample() {
      bitField0_ &= ~0x00000020;
      sample.clear();
      return this;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</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 #getMutableSample()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public TravelerDuelRankUpload.TravelerDuelBattleSamples getSample() {
      return sample;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</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 TravelerDuelRankUpload.TravelerDuelBattleSamples getMutableSample() {
      bitField0_ |= 0x00000020;
      return sample;
    }

    /**
     * <code>optional .TravelerDuelBattleSamples sample = 3;</code>
     * @param value the sample to set
     * @return this
     */
    public ScoreBossSettleReq setSample(
        final TravelerDuelRankUpload.TravelerDuelBattleSamples value) {
      bitField0_ |= 0x00000020;
      sample.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @return whether the events field is set
     */
    public boolean hasEvents() {
      return (bitField0_ & 0x00000040) != 0;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @return this
     */
    public ScoreBossSettleReq clearEvents() {
      bitField0_ &= ~0x00000040;
      events.clear();
      return this;
    }

    /**
     * <code>optional .Events Events = 15;</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 #getMutableEvents()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.Events getEvents() {
      return events;
    }

    /**
     * <code>optional .Events Events = 15;</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 Public.Events getMutableEvents() {
      bitField0_ |= 0x00000040;
      return events;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @param value the events to set
     * @return this
     */
    public ScoreBossSettleReq setEvents(final Public.Events value) {
      bitField0_ |= 0x00000040;
      events.copyFrom(value);
      return this;
    }

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ScoreBossSettleReq clearNextPackage() {
      bitField0_ &= ~0x00000080;
      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_ |= 0x00000080;
      return nextPackage;
    }

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

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

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

    @Override
    public ScoreBossSettleReq copyFrom(final ScoreBossSettleReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        star = other.star;
        score = other.score;
        damageScore = other.damageScore;
        skillScore = other.skillScore;
        bossResultLevel = other.bossResultLevel;
        sample.copyFrom(other.sample);
        events.copyFrom(other.events);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ScoreBossSettleReq mergeFrom(final ScoreBossSettleReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasStar()) {
        setStar(other.star);
      }
      if (other.hasScore()) {
        setScore(other.score);
      }
      if (other.hasDamageScore()) {
        setDamageScore(other.damageScore);
      }
      if (other.hasSkillScore()) {
        setSkillScore(other.skillScore);
      }
      if (other.hasBossResultLevel()) {
        setBossResultLevel(other.bossResultLevel);
      }
      if (other.hasSample()) {
        getMutableSample().mergeFrom(other.sample);
      }
      if (other.hasEvents()) {
        getMutableEvents().mergeFrom(other.events);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ScoreBossSettleReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      star = 0;
      score = 0;
      damageScore = 0;
      skillScore = 0;
      bossResultLevel = 0;
      sample.clear();
      events.clear();
      nextPackage.clear();
      return this;
    }

    @Override
    public ScoreBossSettleReq clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      sample.clearQuick();
      events.clearQuick();
      nextPackage.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ScoreBossSettleReq)) {
        return false;
      }
      ScoreBossSettleReq other = (ScoreBossSettleReq) o;
      return bitField0_ == other.bitField0_
        && (!hasStar() || star == other.star)
        && (!hasScore() || score == other.score)
        && (!hasDamageScore() || damageScore == other.damageScore)
        && (!hasSkillScore() || skillScore == other.skillScore)
        && (!hasBossResultLevel() || bossResultLevel == other.bossResultLevel)
        && (!hasSample() || sample.equals(other.sample))
        && (!hasEvents() || events.equals(other.events))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(star);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(damageScore);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(skillScore);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(bossResultLevel);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 26);
        output.writeMessageNoTag(sample);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeRawByte((byte) 122);
        output.writeMessageNoTag(events);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(star);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(damageScore);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(skillScore);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(bossResultLevel);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(sample);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(events);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ScoreBossSettleReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // star
            star = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // score
            score = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // damageScore
            damageScore = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // skillScore
            skillScore = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // bossResultLevel
            bossResultLevel = input.readUInt32();
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // sample
            input.readMessage(sample);
            bitField0_ |= 0x00000020;
            tag = input.readTag();
            if (tag != 122) {
              break;
            }
          }
          case 122: {
            // events
            input.readMessage(events);
            bitField0_ |= 0x00000040;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000080;
            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_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.star, star);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.score, score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.damageScore, damageScore);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.skillScore, skillScore);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.bossResultLevel, bossResultLevel);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeMessage(FieldNames.sample, sample);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeMessage(FieldNames.events, events);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public ScoreBossSettleReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2587250: {
            if (input.isAtField(FieldNames.star)) {
              if (!input.trySkipNullValue()) {
                star = 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 -1815857085: {
            if (input.isAtField(FieldNames.damageScore)) {
              if (!input.trySkipNullValue()) {
                damageScore = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -705549599: {
            if (input.isAtField(FieldNames.skillScore)) {
              if (!input.trySkipNullValue()) {
                skillScore = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -172418150: {
            if (input.isAtField(FieldNames.bossResultLevel)) {
              if (!input.trySkipNullValue()) {
                bossResultLevel = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -909675094: {
            if (input.isAtField(FieldNames.sample)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(sample);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2087505209: {
            if (input.isAtField(FieldNames.events)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(events);
                bitField0_ |= 0x00000040;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000080;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ScoreBossSettleReqFactory implements MessageFactory<ScoreBossSettleReq> {
      INSTANCE;

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

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

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

      static final FieldName damageScore = FieldName.forField("DamageScore");

      static final FieldName skillScore = FieldName.forField("SkillScore");

      static final FieldName bossResultLevel = FieldName.forField("BossResultLevel");

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

      static final FieldName events = FieldName.forField("Events");

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

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

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

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

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

    /**
     * <code>optional string token = 1;</code>
     */
    private final Utf8String token = Utf8String.newEmptyInstance();

    private ScoreBossSettleResp() {
    }

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

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

    /**
     * <code>optional uint32 oldRank = 2;</code>
     * @return this
     */
    public ScoreBossSettleResp clearOldRank() {
      bitField0_ &= ~0x00000001;
      oldRank = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 oldRank = 2;</code>
     * @param value the oldRank to set
     * @return this
     */
    public ScoreBossSettleResp setOldRank(final int value) {
      bitField0_ |= 0x00000001;
      oldRank = value;
      return this;
    }

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

    /**
     * <code>optional uint32 newRank = 3;</code>
     * @return this
     */
    public ScoreBossSettleResp clearNewRank() {
      bitField0_ &= ~0x00000002;
      newRank = 0;
      return this;
    }

    /**
     * <code>optional uint32 newRank = 3;</code>
     * @return the newRank
     */
    public int getNewRank() {
      return newRank;
    }

    /**
     * <code>optional uint32 newRank = 3;</code>
     * @param value the newRank to set
     * @return this
     */
    public ScoreBossSettleResp setNewRank(final int value) {
      bitField0_ |= 0x00000002;
      newRank = value;
      return this;
    }

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ScoreBossSettleResp clearNextPackage() {
      bitField0_ &= ~0x00000004;
      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_ |= 0x00000004;
      return nextPackage;
    }

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

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

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

    /**
     * <code>optional string token = 1;</code>
     * @return whether the token field is set
     */
    public boolean hasToken() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional string token = 1;</code>
     * @return this
     */
    public ScoreBossSettleResp clearToken() {
      bitField0_ &= ~0x00000008;
      token.clear();
      return this;
    }

    /**
     * <code>optional string token = 1;</code>
     * @return the token
     */
    public String getToken() {
      return token.getString();
    }

    /**
     * <code>optional string token = 1;</code>
     * @return internal {@code Utf8String} representation of token for reading
     */
    public Utf8String getTokenBytes() {
      return this.token;
    }

    /**
     * <code>optional string token = 1;</code>
     * @return internal {@code Utf8String} representation of token for modifications
     */
    public Utf8String getMutableTokenBytes() {
      bitField0_ |= 0x00000008;
      return this.token;
    }

    /**
     * <code>optional string token = 1;</code>
     * @param value the token to set
     * @return this
     */
    public ScoreBossSettleResp setToken(final CharSequence value) {
      bitField0_ |= 0x00000008;
      token.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string token = 1;</code>
     * @param value the token to set
     * @return this
     */
    public ScoreBossSettleResp setToken(final Utf8String value) {
      bitField0_ |= 0x00000008;
      token.copyFrom(value);
      return this;
    }

    @Override
    public ScoreBossSettleResp copyFrom(final ScoreBossSettleResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        oldRank = other.oldRank;
        newRank = other.newRank;
        nextPackage.copyFrom(other.nextPackage);
        token.copyFrom(other.token);
      }
      return this;
    }

    @Override
    public ScoreBossSettleResp mergeFrom(final ScoreBossSettleResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasOldRank()) {
        setOldRank(other.oldRank);
      }
      if (other.hasNewRank()) {
        setNewRank(other.newRank);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasToken()) {
        getMutableTokenBytes().copyFrom(other.token);
      }
      return this;
    }

    @Override
    public ScoreBossSettleResp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      oldRank = 0;
      newRank = 0;
      nextPackage.clear();
      token.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ScoreBossSettleResp)) {
        return false;
      }
      ScoreBossSettleResp other = (ScoreBossSettleResp) o;
      return bitField0_ == other.bitField0_
        && (!hasOldRank() || oldRank == other.oldRank)
        && (!hasNewRank() || newRank == other.newRank)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasToken() || token.equals(other.token));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(oldRank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(newRank);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(token);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(oldRank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(newRank);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeStringSizeNoTag(token);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ScoreBossSettleResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // oldRank
            oldRank = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // newRank
            newRank = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // token
            input.readString(token);
            bitField0_ |= 0x00000008;
            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_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.oldRank, oldRank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.newRank, newRank);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeString(FieldNames.token, token);
      }
      output.endObject();
    }

    @Override
    public ScoreBossSettleResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1379466509: {
            if (input.isAtField(FieldNames.oldRank)) {
              if (!input.trySkipNullValue()) {
                oldRank = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1845139948: {
            if (input.isAtField(FieldNames.newRank)) {
              if (!input.trySkipNullValue()) {
                newRank = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 110541305: {
            if (input.isAtField(FieldNames.token)) {
              if (!input.trySkipNullValue()) {
                input.readString(token);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ScoreBossSettleRespFactory implements MessageFactory<ScoreBossSettleResp> {
      INSTANCE;

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

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

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

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

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