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

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

    /**
     * <code>optional uint32 DuelLevel = 1;</code>
     */
    private int duelLevel;

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

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

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</code>
     */
    private final Public.TravelerDuelChallengeInfo challenge = Public.TravelerDuelChallengeInfo.newInstance();

    /**
     * <code>optional .Quests Quests = 6;</code>
     */
    private final Public.Quests quests = Public.Quests.newInstance();

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

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

    private TravelerDuelInfo() {
    }

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

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

    /**
     * <code>optional uint32 DuelLevel = 1;</code>
     * @return this
     */
    public TravelerDuelInfo clearDuelLevel() {
      bitField0_ &= ~0x00000001;
      duelLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 DuelLevel = 1;</code>
     * @return the duelLevel
     */
    public int getDuelLevel() {
      return duelLevel;
    }

    /**
     * <code>optional uint32 DuelLevel = 1;</code>
     * @param value the duelLevel to set
     * @return this
     */
    public TravelerDuelInfo setDuelLevel(final int value) {
      bitField0_ |= 0x00000001;
      duelLevel = value;
      return this;
    }

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

    /**
     * <code>optional uint32 DuelExp = 2;</code>
     * @return this
     */
    public TravelerDuelInfo clearDuelExp() {
      bitField0_ &= ~0x00000002;
      duelExp = 0;
      return this;
    }

    /**
     * <code>optional uint32 DuelExp = 2;</code>
     * @return the duelExp
     */
    public int getDuelExp() {
      return duelExp;
    }

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

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

    /**
     * <code>optional uint32 WeeklyAwardTimes = 3;</code>
     * @return this
     */
    public TravelerDuelInfo clearWeeklyAwardTimes() {
      bitField0_ &= ~0x00000004;
      weeklyAwardTimes = 0;
      return this;
    }

    /**
     * <code>optional uint32 WeeklyAwardTimes = 3;</code>
     * @return the weeklyAwardTimes
     */
    public int getWeeklyAwardTimes() {
      return weeklyAwardTimes;
    }

    /**
     * <code>optional uint32 WeeklyAwardTimes = 3;</code>
     * @param value the weeklyAwardTimes to set
     * @return this
     */
    public TravelerDuelInfo setWeeklyAwardTimes(final int value) {
      bitField0_ |= 0x00000004;
      weeklyAwardTimes = value;
      return this;
    }

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</code>
     * @return whether the challenge field is set
     */
    public boolean hasChallenge() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</code>
     * @return this
     */
    public TravelerDuelInfo clearChallenge() {
      bitField0_ &= ~0x00000008;
      challenge.clear();
      return this;
    }

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</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 #getMutableChallenge()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.TravelerDuelChallengeInfo getChallenge() {
      return challenge;
    }

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</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.TravelerDuelChallengeInfo getMutableChallenge() {
      bitField0_ |= 0x00000008;
      return challenge;
    }

    /**
     * <code>optional .TravelerDuelChallengeInfo Challenge = 5;</code>
     * @param value the challenge to set
     * @return this
     */
    public TravelerDuelInfo setChallenge(final Public.TravelerDuelChallengeInfo value) {
      bitField0_ |= 0x00000008;
      challenge.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .Quests Quests = 6;</code>
     * @return whether the quests field is set
     */
    public boolean hasQuests() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional .Quests Quests = 6;</code>
     * @return this
     */
    public TravelerDuelInfo clearQuests() {
      bitField0_ &= ~0x00000010;
      quests.clear();
      return this;
    }

    /**
     * <code>optional .Quests Quests = 6;</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 #getMutableQuests()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.Quests getQuests() {
      return quests;
    }

    /**
     * <code>optional .Quests Quests = 6;</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.Quests getMutableQuests() {
      bitField0_ |= 0x00000010;
      return quests;
    }

    /**
     * <code>optional .Quests Quests = 6;</code>
     * @param value the quests to set
     * @return this
     */
    public TravelerDuelInfo setQuests(final Public.Quests value) {
      bitField0_ |= 0x00000010;
      quests.copyFrom(value);
      return this;
    }

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

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

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

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

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

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

    /**
     * <code>repeated .TravelerDuelBossLevel Levels = 4;</code>
     * @return this
     */
    public TravelerDuelInfo clearLevels() {
      bitField0_ &= ~0x00000040;
      levels.clear();
      return this;
    }

    /**
     * <code>repeated .TravelerDuelBossLevel Levels = 4;</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.TravelerDuelBossLevel> getLevels() {
      return levels;
    }

    /**
     * <code>repeated .TravelerDuelBossLevel Levels = 4;</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.TravelerDuelBossLevel> getMutableLevels() {
      bitField0_ |= 0x00000040;
      return levels;
    }

    /**
     * <code>repeated .TravelerDuelBossLevel Levels = 4;</code>
     * @param value the levels to add
     * @return this
     */
    public TravelerDuelInfo addLevels(final Public.TravelerDuelBossLevel value) {
      bitField0_ |= 0x00000040;
      levels.add(value);
      return this;
    }

    /**
     * <code>repeated .TravelerDuelBossLevel Levels = 4;</code>
     * @param values the levels to add
     * @return this
     */
    public TravelerDuelInfo addAllLevels(final Public.TravelerDuelBossLevel... values) {
      bitField0_ |= 0x00000040;
      levels.addAll(values);
      return this;
    }

    @Override
    public TravelerDuelInfo copyFrom(final TravelerDuelInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        duelLevel = other.duelLevel;
        duelExp = other.duelExp;
        weeklyAwardTimes = other.weeklyAwardTimes;
        challenge.copyFrom(other.challenge);
        quests.copyFrom(other.quests);
        nextPackage.copyFrom(other.nextPackage);
        levels.copyFrom(other.levels);
      }
      return this;
    }

    @Override
    public TravelerDuelInfo mergeFrom(final TravelerDuelInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasDuelLevel()) {
        setDuelLevel(other.duelLevel);
      }
      if (other.hasDuelExp()) {
        setDuelExp(other.duelExp);
      }
      if (other.hasWeeklyAwardTimes()) {
        setWeeklyAwardTimes(other.weeklyAwardTimes);
      }
      if (other.hasChallenge()) {
        getMutableChallenge().mergeFrom(other.challenge);
      }
      if (other.hasQuests()) {
        getMutableQuests().mergeFrom(other.quests);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasLevels()) {
        getMutableLevels().addAll(other.levels);
      }
      return this;
    }

    @Override
    public TravelerDuelInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      duelLevel = 0;
      duelExp = 0;
      weeklyAwardTimes = 0;
      challenge.clear();
      quests.clear();
      nextPackage.clear();
      levels.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof TravelerDuelInfo)) {
        return false;
      }
      TravelerDuelInfo other = (TravelerDuelInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasDuelLevel() || duelLevel == other.duelLevel)
        && (!hasDuelExp() || duelExp == other.duelExp)
        && (!hasWeeklyAwardTimes() || weeklyAwardTimes == other.weeklyAwardTimes)
        && (!hasChallenge() || challenge.equals(other.challenge))
        && (!hasQuests() || quests.equals(other.quests))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasLevels() || levels.equals(other.levels));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(duelLevel);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(duelExp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(weeklyAwardTimes);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 42);
        output.writeMessageNoTag(challenge);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 50);
        output.writeMessageNoTag(quests);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        for (int i = 0; i < levels.length(); i++) {
          output.writeRawByte((byte) 34);
          output.writeMessageNoTag(levels.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(duelLevel);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(duelExp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(weeklyAwardTimes);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(challenge);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(quests);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        size += (1 * levels.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(levels);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public TravelerDuelInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // duelLevel
            duelLevel = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // duelExp
            duelExp = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // weeklyAwardTimes
            weeklyAwardTimes = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 42) {
              break;
            }
          }
          case 42: {
            // challenge
            input.readMessage(challenge);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // quests
            input.readMessage(quests);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000020;
            tag = input.readTag();
            if (tag != 34) {
              break;
            }
          }
          case 34: {
            // levels
            tag = input.readRepeatedMessage(levels, tag);
            bitField0_ |= 0x00000040;
            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.duelLevel, duelLevel);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.duelExp, duelExp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.weeklyAwardTimes, weeklyAwardTimes);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeMessage(FieldNames.challenge, challenge);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeMessage(FieldNames.quests, quests);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeRepeatedMessage(FieldNames.levels, levels);
      }
      output.endObject();
    }

    @Override
    public TravelerDuelInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2006347084: {
            if (input.isAtField(FieldNames.duelLevel)) {
              if (!input.trySkipNullValue()) {
                duelLevel = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -628085275: {
            if (input.isAtField(FieldNames.duelExp)) {
              if (!input.trySkipNullValue()) {
                duelExp = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 355811946: {
            if (input.isAtField(FieldNames.weeklyAwardTimes)) {
              if (!input.trySkipNullValue()) {
                weeklyAwardTimes = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -888366013: {
            if (input.isAtField(FieldNames.challenge)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(challenge);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1864830991: {
            if (input.isAtField(FieldNames.quests)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(quests);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2022260337: {
            if (input.isAtField(FieldNames.levels)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(levels);
                bitField0_ |= 0x00000040;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum TravelerDuelInfoFactory implements MessageFactory<TravelerDuelInfo> {
      INSTANCE;

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

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

      static final FieldName duelExp = FieldName.forField("DuelExp");

      static final FieldName weeklyAwardTimes = FieldName.forField("WeeklyAwardTimes");

      static final FieldName challenge = FieldName.forField("Challenge");

      static final FieldName quests = FieldName.forField("Quests");

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

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