// 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;
import us.hebi.quickbuf.RepeatedInt;

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

    /**
     * <code>optional int64 finish_time = 3;</code>
     */
    private long finishTime;

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

    /**
     * <code>optional uint32 id = 13;</code>
     */
    private int id;

    /**
     * <code>optional .QuestStatus status = 8;</code>
     */
    private int status;

    /**
     * <code>repeated uint32 params = 1;</code>
     */
    private final RepeatedInt params = RepeatedInt.newEmptyInstance();

    private Quest() {
    }

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

    /**
     * <code>optional int64 finish_time = 3;</code>
     * @return whether the finishTime field is set
     */
    public boolean hasFinishTime() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional int64 finish_time = 3;</code>
     * @return this
     */
    public Quest clearFinishTime() {
      bitField0_ &= ~0x00000001;
      finishTime = 0L;
      return this;
    }

    /**
     * <code>optional int64 finish_time = 3;</code>
     * @return the finishTime
     */
    public long getFinishTime() {
      return finishTime;
    }

    /**
     * <code>optional int64 finish_time = 3;</code>
     * @param value the finishTime to set
     * @return this
     */
    public Quest setFinishTime(final long value) {
      bitField0_ |= 0x00000001;
      finishTime = value;
      return this;
    }

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

    /**
     * <code>optional uint32 progress = 2;</code>
     * @return this
     */
    public Quest clearProgress() {
      bitField0_ &= ~0x00000002;
      progress = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 id = 13;</code>
     * @return this
     */
    public Quest clearId() {
      bitField0_ &= ~0x00000004;
      id = 0;
      return this;
    }

    /**
     * <code>optional uint32 id = 13;</code>
     * @return the id
     */
    public int getId() {
      return id;
    }

    /**
     * <code>optional uint32 id = 13;</code>
     * @param value the id to set
     * @return this
     */
    public Quest setId(final int value) {
      bitField0_ |= 0x00000004;
      id = value;
      return this;
    }

    /**
     * <code>optional .QuestStatus status = 8;</code>
     * @return whether the status field is set
     */
    public boolean hasStatus() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional .QuestStatus status = 8;</code>
     * @return this
     */
    public Quest clearStatus() {
      bitField0_ &= ~0x00000008;
      status = 0;
      return this;
    }

    /**
     * <code>optional .QuestStatus status = 8;</code>
     * @return the status
     */
    public QuestStatusOuterClass.QuestStatus getStatus() {
      return QuestStatusOuterClass.QuestStatus.forNumber(status);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link Quest#getStatus()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getStatusValue() {
      return status;
    }

    /**
     * Sets the value of the internal enum store. This does not
     * do any validity checks, so be sure to use appropriate value
     * constants from {@link QuestStatusOuterClass.QuestStatus}. Setting an invalid value
     * can cause {@link Quest#getStatus()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public Quest setStatusValue(final int value) {
      bitField0_ |= 0x00000008;
      status = value;
      return this;
    }

    /**
     * <code>optional .QuestStatus status = 8;</code>
     * @param value the status to set
     * @return this
     */
    public Quest setStatus(final QuestStatusOuterClass.QuestStatus value) {
      bitField0_ |= 0x00000008;
      status = value.getNumber();
      return this;
    }

    /**
     * <code>repeated uint32 params = 1;</code>
     * @return whether the params field is set
     */
    public boolean hasParams() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>repeated uint32 params = 1;</code>
     * @return this
     */
    public Quest clearParams() {
      bitField0_ &= ~0x00000010;
      params.clear();
      return this;
    }

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

    /**
     * <code>repeated uint32 params = 1;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedInt getMutableParams() {
      bitField0_ |= 0x00000010;
      return params;
    }

    /**
     * <code>repeated uint32 params = 1;</code>
     * @param value the params to add
     * @return this
     */
    public Quest addParams(final int value) {
      bitField0_ |= 0x00000010;
      params.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 params = 1;</code>
     * @param values the params to add
     * @return this
     */
    public Quest addAllParams(final int... values) {
      bitField0_ |= 0x00000010;
      params.addAll(values);
      return this;
    }

    @Override
    public Quest copyFrom(final Quest other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        finishTime = other.finishTime;
        progress = other.progress;
        id = other.id;
        status = other.status;
        params.copyFrom(other.params);
      }
      return this;
    }

    @Override
    public Quest mergeFrom(final Quest other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasFinishTime()) {
        setFinishTime(other.finishTime);
      }
      if (other.hasProgress()) {
        setProgress(other.progress);
      }
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasStatus()) {
        setStatusValue(other.status);
      }
      if (other.hasParams()) {
        getMutableParams().addAll(other.params);
      }
      return this;
    }

    @Override
    public Quest clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      finishTime = 0L;
      progress = 0;
      id = 0;
      status = 0;
      params.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof Quest)) {
        return false;
      }
      Quest other = (Quest) o;
      return bitField0_ == other.bitField0_
        && (!hasFinishTime() || finishTime == other.finishTime)
        && (!hasProgress() || progress == other.progress)
        && (!hasId() || id == other.id)
        && (!hasStatus() || status == other.status)
        && (!hasParams() || params.equals(other.params));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeInt64NoTag(finishTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(progress);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 104);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 64);
        output.writeEnumNoTag(status);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        for (int i = 0; i < params.length(); i++) {
          output.writeRawByte((byte) 8);
          output.writeUInt32NoTag(params.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeInt64SizeNoTag(finishTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(progress);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(id);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(status);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += (1 * params.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(params);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public Quest mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // finishTime
            finishTime = input.readInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // progress
            progress = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 104) {
              break;
            }
          }
          case 104: {
            // id
            id = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // status
            final int value = input.readInt32();
            if (QuestStatusOuterClass.QuestStatus.forNumber(value) != null) {
              status = value;
              bitField0_ |= 0x00000008;
            }
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // params [packed=true]
            input.readPackedUInt32(params, tag);
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 8: {
            // params [packed=false]
            tag = input.readRepeatedUInt32(params, tag);
            bitField0_ |= 0x00000010;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeInt64(FieldNames.finishTime, finishTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.progress, progress);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.id, id);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeEnum(FieldNames.status, status, QuestStatusOuterClass.QuestStatus.converter());
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRepeatedUInt32(FieldNames.params, params);
      }
      output.endObject();
    }

    @Override
    public Quest mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1151521280:
          case 1347904249: {
            if (input.isAtField(FieldNames.finishTime)) {
              if (!input.trySkipNullValue()) {
                finishTime = input.readInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1001078227: {
            if (input.isAtField(FieldNames.progress)) {
              if (!input.trySkipNullValue()) {
                progress = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3355: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -892481550: {
            if (input.isAtField(FieldNames.status)) {
              if (!input.trySkipNullValue()) {
                final QuestStatusOuterClass.QuestStatus value = input.readEnum(QuestStatusOuterClass.QuestStatus.converter());
                if (value != null) {
                  status = value.getNumber();
                  bitField0_ |= 0x00000008;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -995427962: {
            if (input.isAtField(FieldNames.params)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(params);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum QuestFactory implements MessageFactory<Quest> {
      INSTANCE;

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

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

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

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

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

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