// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.proto;

import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;

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

    /**
     * <code>optional uint32 score_two = 1;</code>
     */
    private int scoreTwo;

    /**
     * <code>optional uint32 taken_reward = 6;</code>
     */
    private int takenReward;

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

    /**
     * <code>optional uint32 challenge_id = 9;</code>
     */
    private int challengeId;

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

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</code>
     */
    private final ChallengeExtInfoOuterClass.ChallengeExtInfo extInfo = ChallengeExtInfoOuterClass.ChallengeExtInfo.newInstance();

    private Challenge() {
    }

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

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

    /**
     * <code>optional uint32 score_two = 1;</code>
     * @return this
     */
    public Challenge clearScoreTwo() {
      bitField0_ &= ~0x00000001;
      scoreTwo = 0;
      return this;
    }

    /**
     * <code>optional uint32 score_two = 1;</code>
     * @return the scoreTwo
     */
    public int getScoreTwo() {
      return scoreTwo;
    }

    /**
     * <code>optional uint32 score_two = 1;</code>
     * @param value the scoreTwo to set
     * @return this
     */
    public Challenge setScoreTwo(final int value) {
      bitField0_ |= 0x00000001;
      scoreTwo = value;
      return this;
    }

    /**
     * <code>optional uint32 taken_reward = 6;</code>
     * @return whether the takenReward field is set
     */
    public boolean hasTakenReward() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 taken_reward = 6;</code>
     * @return this
     */
    public Challenge clearTakenReward() {
      bitField0_ &= ~0x00000002;
      takenReward = 0;
      return this;
    }

    /**
     * <code>optional uint32 taken_reward = 6;</code>
     * @return the takenReward
     */
    public int getTakenReward() {
      return takenReward;
    }

    /**
     * <code>optional uint32 taken_reward = 6;</code>
     * @param value the takenReward to set
     * @return this
     */
    public Challenge setTakenReward(final int value) {
      bitField0_ |= 0x00000002;
      takenReward = value;
      return this;
    }

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

    /**
     * <code>optional uint32 score = 8;</code>
     * @return this
     */
    public Challenge clearScore() {
      bitField0_ &= ~0x00000004;
      score = 0;
      return this;
    }

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

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

    /**
     * <code>optional uint32 challenge_id = 9;</code>
     * @return whether the challengeId field is set
     */
    public boolean hasChallengeId() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 challenge_id = 9;</code>
     * @return this
     */
    public Challenge clearChallengeId() {
      bitField0_ &= ~0x00000008;
      challengeId = 0;
      return this;
    }

    /**
     * <code>optional uint32 challenge_id = 9;</code>
     * @return the challengeId
     */
    public int getChallengeId() {
      return challengeId;
    }

    /**
     * <code>optional uint32 challenge_id = 9;</code>
     * @param value the challengeId to set
     * @return this
     */
    public Challenge setChallengeId(final int value) {
      bitField0_ |= 0x00000008;
      challengeId = value;
      return this;
    }

    /**
     * <code>optional uint32 stars = 14;</code>
     * @return whether the stars field is set
     */
    public boolean hasStars() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional uint32 stars = 14;</code>
     * @return this
     */
    public Challenge clearStars() {
      bitField0_ &= ~0x00000010;
      stars = 0;
      return this;
    }

    /**
     * <code>optional uint32 stars = 14;</code>
     * @return the stars
     */
    public int getStars() {
      return stars;
    }

    /**
     * <code>optional uint32 stars = 14;</code>
     * @param value the stars to set
     * @return this
     */
    public Challenge setStars(final int value) {
      bitField0_ |= 0x00000010;
      stars = value;
      return this;
    }

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</code>
     * @return whether the extInfo field is set
     */
    public boolean hasExtInfo() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</code>
     * @return this
     */
    public Challenge clearExtInfo() {
      bitField0_ &= ~0x00000020;
      extInfo.clear();
      return this;
    }

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</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 #getMutableExtInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ChallengeExtInfoOuterClass.ChallengeExtInfo getExtInfo() {
      return extInfo;
    }

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</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 ChallengeExtInfoOuterClass.ChallengeExtInfo getMutableExtInfo() {
      bitField0_ |= 0x00000020;
      return extInfo;
    }

    /**
     * <code>optional .ChallengeExtInfo ext_info = 10;</code>
     * @param value the extInfo to set
     * @return this
     */
    public Challenge setExtInfo(final ChallengeExtInfoOuterClass.ChallengeExtInfo value) {
      bitField0_ |= 0x00000020;
      extInfo.copyFrom(value);
      return this;
    }

    @Override
    public Challenge copyFrom(final Challenge other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        scoreTwo = other.scoreTwo;
        takenReward = other.takenReward;
        score = other.score;
        challengeId = other.challengeId;
        stars = other.stars;
        extInfo.copyFrom(other.extInfo);
      }
      return this;
    }

    @Override
    public Challenge mergeFrom(final Challenge other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasScoreTwo()) {
        setScoreTwo(other.scoreTwo);
      }
      if (other.hasTakenReward()) {
        setTakenReward(other.takenReward);
      }
      if (other.hasScore()) {
        setScore(other.score);
      }
      if (other.hasChallengeId()) {
        setChallengeId(other.challengeId);
      }
      if (other.hasStars()) {
        setStars(other.stars);
      }
      if (other.hasExtInfo()) {
        getMutableExtInfo().mergeFrom(other.extInfo);
      }
      return this;
    }

    @Override
    public Challenge clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      scoreTwo = 0;
      takenReward = 0;
      score = 0;
      challengeId = 0;
      stars = 0;
      extInfo.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof Challenge)) {
        return false;
      }
      Challenge other = (Challenge) o;
      return bitField0_ == other.bitField0_
        && (!hasScoreTwo() || scoreTwo == other.scoreTwo)
        && (!hasTakenReward() || takenReward == other.takenReward)
        && (!hasScore() || score == other.score)
        && (!hasChallengeId() || challengeId == other.challengeId)
        && (!hasStars() || stars == other.stars)
        && (!hasExtInfo() || extInfo.equals(other.extInfo));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(scoreTwo);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(takenReward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(score);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 72);
        output.writeUInt32NoTag(challengeId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(stars);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 82);
        output.writeMessageNoTag(extInfo);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(scoreTwo);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(takenReward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(score);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(challengeId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(stars);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(extInfo);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public Challenge mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // scoreTwo
            scoreTwo = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // takenReward
            takenReward = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // score
            score = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 72) {
              break;
            }
          }
          case 72: {
            // challengeId
            challengeId = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // stars
            stars = input.readUInt32();
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 82) {
              break;
            }
          }
          case 82: {
            // extInfo
            input.readMessage(extInfo);
            bitField0_ |= 0x00000020;
            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.scoreTwo, scoreTwo);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.takenReward, takenReward);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.score, score);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.challengeId, challengeId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.stars, stars);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeMessage(FieldNames.extInfo, extInfo);
      }
      output.endObject();
    }

    @Override
    public Challenge mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -485512614:
          case 2129303327: {
            if (input.isAtField(FieldNames.scoreTwo)) {
              if (!input.trySkipNullValue()) {
                scoreTwo = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1216849622:
          case -1923526233: {
            if (input.isAtField(FieldNames.takenReward)) {
              if (!input.trySkipNullValue()) {
                takenReward = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 109264530: {
            if (input.isAtField(FieldNames.score)) {
              if (!input.trySkipNullValue()) {
                score = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -689112866:
          case 112359031: {
            if (input.isAtField(FieldNames.challengeId)) {
              if (!input.trySkipNullValue()) {
                challengeId = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 109757537: {
            if (input.isAtField(FieldNames.stars)) {
              if (!input.trySkipNullValue()) {
                stars = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1306498449:
          case -1826570228: {
            if (input.isAtField(FieldNames.extInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(extInfo);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ChallengeFactory implements MessageFactory<Challenge> {
      INSTANCE;

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

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

      static final FieldName takenReward = FieldName.forField("takenReward", "taken_reward");

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

      static final FieldName challengeId = FieldName.forField("challengeId", "challenge_id");

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

      static final FieldName extInfo = FieldName.forField("extInfo", "ext_info");
    }
  }
}
