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

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

    /**
     * <code>optional uint32 world_level = 9;</code>
     */
    private int worldLevel;

    /**
     * <code>optional uint32 farm_element_id = 15;</code>
     */
    private int farmElementId;

    private QuickStartFarmElementCsReq() {
    }

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

    /**
     * <code>optional uint32 wave_count = 2;</code>
     * @return whether the waveCount field is set
     */
    public boolean hasWaveCount() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 wave_count = 2;</code>
     * @return this
     */
    public QuickStartFarmElementCsReq clearWaveCount() {
      bitField0_ &= ~0x00000001;
      waveCount = 0;
      return this;
    }

    /**
     * <code>optional uint32 wave_count = 2;</code>
     * @return the waveCount
     */
    public int getWaveCount() {
      return waveCount;
    }

    /**
     * <code>optional uint32 wave_count = 2;</code>
     * @param value the waveCount to set
     * @return this
     */
    public QuickStartFarmElementCsReq setWaveCount(final int value) {
      bitField0_ |= 0x00000001;
      waveCount = value;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 9;</code>
     * @return whether the worldLevel field is set
     */
    public boolean hasWorldLevel() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 world_level = 9;</code>
     * @return this
     */
    public QuickStartFarmElementCsReq clearWorldLevel() {
      bitField0_ &= ~0x00000002;
      worldLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 9;</code>
     * @return the worldLevel
     */
    public int getWorldLevel() {
      return worldLevel;
    }

    /**
     * <code>optional uint32 world_level = 9;</code>
     * @param value the worldLevel to set
     * @return this
     */
    public QuickStartFarmElementCsReq setWorldLevel(final int value) {
      bitField0_ |= 0x00000002;
      worldLevel = value;
      return this;
    }

    /**
     * <code>optional uint32 farm_element_id = 15;</code>
     * @return whether the farmElementId field is set
     */
    public boolean hasFarmElementId() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 farm_element_id = 15;</code>
     * @return this
     */
    public QuickStartFarmElementCsReq clearFarmElementId() {
      bitField0_ &= ~0x00000004;
      farmElementId = 0;
      return this;
    }

    /**
     * <code>optional uint32 farm_element_id = 15;</code>
     * @return the farmElementId
     */
    public int getFarmElementId() {
      return farmElementId;
    }

    /**
     * <code>optional uint32 farm_element_id = 15;</code>
     * @param value the farmElementId to set
     * @return this
     */
    public QuickStartFarmElementCsReq setFarmElementId(final int value) {
      bitField0_ |= 0x00000004;
      farmElementId = value;
      return this;
    }

    @Override
    public QuickStartFarmElementCsReq copyFrom(final QuickStartFarmElementCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        waveCount = other.waveCount;
        worldLevel = other.worldLevel;
        farmElementId = other.farmElementId;
      }
      return this;
    }

    @Override
    public QuickStartFarmElementCsReq mergeFrom(final QuickStartFarmElementCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasWaveCount()) {
        setWaveCount(other.waveCount);
      }
      if (other.hasWorldLevel()) {
        setWorldLevel(other.worldLevel);
      }
      if (other.hasFarmElementId()) {
        setFarmElementId(other.farmElementId);
      }
      return this;
    }

    @Override
    public QuickStartFarmElementCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      waveCount = 0;
      worldLevel = 0;
      farmElementId = 0;
      return this;
    }

    @Override
    public QuickStartFarmElementCsReq 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 QuickStartFarmElementCsReq)) {
        return false;
      }
      QuickStartFarmElementCsReq other = (QuickStartFarmElementCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasWaveCount() || waveCount == other.waveCount)
        && (!hasWorldLevel() || worldLevel == other.worldLevel)
        && (!hasFarmElementId() || farmElementId == other.farmElementId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(waveCount);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 72);
        output.writeUInt32NoTag(worldLevel);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt32NoTag(farmElementId);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public QuickStartFarmElementCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // waveCount
            waveCount = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 72) {
              break;
            }
          }
          case 72: {
            // worldLevel
            worldLevel = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 120) {
              break;
            }
          }
          case 120: {
            // farmElementId
            farmElementId = input.readUInt32();
            bitField0_ |= 0x00000004;
            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.waveCount, waveCount);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.worldLevel, worldLevel);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.farmElementId, farmElementId);
      }
      output.endObject();
    }

    @Override
    public QuickStartFarmElementCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1518256534:
          case 611674185: {
            if (input.isAtField(FieldNames.waveCount)) {
              if (!input.trySkipNullValue()) {
                waveCount = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 440007442:
          case 1305257111: {
            if (input.isAtField(FieldNames.worldLevel)) {
              if (!input.trySkipNullValue()) {
                worldLevel = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1414890079:
          case 1118077159: {
            if (input.isAtField(FieldNames.farmElementId)) {
              if (!input.trySkipNullValue()) {
                farmElementId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum QuickStartFarmElementCsReqFactory implements MessageFactory<QuickStartFarmElementCsReq> {
      INSTANCE;

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

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

      static final FieldName worldLevel = FieldName.forField("worldLevel", "world_level");

      static final FieldName farmElementId = FieldName.forField("farmElementId", "farm_element_id");
    }
  }
}
