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

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

    private SelectRogueMiracleCsReq() {
    }

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

    /**
     * <code>optional uint32 miracle_id = 3;</code>
     * @return whether the miracleId field is set
     */
    public boolean hasMiracleId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 miracle_id = 3;</code>
     * @return this
     */
    public SelectRogueMiracleCsReq clearMiracleId() {
      bitField0_ &= ~0x00000001;
      miracleId = 0;
      return this;
    }

    /**
     * <code>optional uint32 miracle_id = 3;</code>
     * @return the miracleId
     */
    public int getMiracleId() {
      return miracleId;
    }

    /**
     * <code>optional uint32 miracle_id = 3;</code>
     * @param value the miracleId to set
     * @return this
     */
    public SelectRogueMiracleCsReq setMiracleId(final int value) {
      bitField0_ |= 0x00000001;
      miracleId = value;
      return this;
    }

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

    @Override
    public SelectRogueMiracleCsReq mergeFrom(final SelectRogueMiracleCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasMiracleId()) {
        setMiracleId(other.miracleId);
      }
      return this;
    }

    @Override
    public SelectRogueMiracleCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      miracleId = 0;
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof SelectRogueMiracleCsReq)) {
        return false;
      }
      SelectRogueMiracleCsReq other = (SelectRogueMiracleCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasMiracleId() || miracleId == other.miracleId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(miracleId);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public SelectRogueMiracleCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // miracleId
            miracleId = input.readUInt32();
            bitField0_ |= 0x00000001;
            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.miracleId, miracleId);
      }
      output.endObject();
    }

    @Override
    public SelectRogueMiracleCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -164571796:
          case -806736983: {
            if (input.isAtField(FieldNames.miracleId)) {
              if (!input.trySkipNullValue()) {
                miracleId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SelectRogueMiracleCsReqFactory implements MessageFactory<SelectRogueMiracleCsReq> {
      INSTANCE;

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

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