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

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

    /**
     * <code>optional .ItemList reward_list = 5;</code>
     */
    private final ItemListOuterClass.ItemList rewardList = ItemListOuterClass.ItemList.newInstance();

    private TakenChallengeRewardInfo() {
    }

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

    /**
     * <code>optional uint32 star_count = 8;</code>
     * @return whether the starCount field is set
     */
    public boolean hasStarCount() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 star_count = 8;</code>
     * @return this
     */
    public TakenChallengeRewardInfo clearStarCount() {
      bitField0_ &= ~0x00000001;
      starCount = 0;
      return this;
    }

    /**
     * <code>optional uint32 star_count = 8;</code>
     * @return the starCount
     */
    public int getStarCount() {
      return starCount;
    }

    /**
     * <code>optional uint32 star_count = 8;</code>
     * @param value the starCount to set
     * @return this
     */
    public TakenChallengeRewardInfo setStarCount(final int value) {
      bitField0_ |= 0x00000001;
      starCount = value;
      return this;
    }

    /**
     * <code>optional .ItemList reward_list = 5;</code>
     * @return whether the rewardList field is set
     */
    public boolean hasRewardList() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .ItemList reward_list = 5;</code>
     * @return this
     */
    public TakenChallengeRewardInfo clearRewardList() {
      bitField0_ &= ~0x00000002;
      rewardList.clear();
      return this;
    }

    /**
     * <code>optional .ItemList reward_list = 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 #getMutableRewardList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public ItemListOuterClass.ItemList getRewardList() {
      return rewardList;
    }

    /**
     * <code>optional .ItemList reward_list = 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 ItemListOuterClass.ItemList getMutableRewardList() {
      bitField0_ |= 0x00000002;
      return rewardList;
    }

    /**
     * <code>optional .ItemList reward_list = 5;</code>
     * @param value the rewardList to set
     * @return this
     */
    public TakenChallengeRewardInfo setRewardList(final ItemListOuterClass.ItemList value) {
      bitField0_ |= 0x00000002;
      rewardList.copyFrom(value);
      return this;
    }

    @Override
    public TakenChallengeRewardInfo copyFrom(final TakenChallengeRewardInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        starCount = other.starCount;
        rewardList.copyFrom(other.rewardList);
      }
      return this;
    }

    @Override
    public TakenChallengeRewardInfo mergeFrom(final TakenChallengeRewardInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasStarCount()) {
        setStarCount(other.starCount);
      }
      if (other.hasRewardList()) {
        getMutableRewardList().mergeFrom(other.rewardList);
      }
      return this;
    }

    @Override
    public TakenChallengeRewardInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      starCount = 0;
      rewardList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof TakenChallengeRewardInfo)) {
        return false;
      }
      TakenChallengeRewardInfo other = (TakenChallengeRewardInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasStarCount() || starCount == other.starCount)
        && (!hasRewardList() || rewardList.equals(other.rewardList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(starCount);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 42);
        output.writeMessageNoTag(rewardList);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(starCount);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(rewardList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public TakenChallengeRewardInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 64: {
            // starCount
            starCount = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 42) {
              break;
            }
          }
          case 42: {
            // rewardList
            input.readMessage(rewardList);
            bitField0_ |= 0x00000002;
            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.starCount, starCount);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.rewardList, rewardList);
      }
      output.endObject();
    }

    @Override
    public TakenChallengeRewardInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2121235933:
          case 2124166370: {
            if (input.isAtField(FieldNames.starCount)) {
              if (!input.trySkipNullValue()) {
                starCount = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1690977389:
          case 898318254: {
            if (input.isAtField(FieldNames.rewardList)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(rewardList);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum TakenChallengeRewardInfoFactory implements MessageFactory<TakenChallengeRewardInfo> {
      INSTANCE;

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

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

      static final FieldName rewardList = FieldName.forField("rewardList", "reward_list");
    }
  }
}
