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

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

    private SceneMonsterWaveParam() {
    }

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

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

    /**
     * <code>optional uint32 level = 14;</code>
     * @return this
     */
    public SceneMonsterWaveParam clearLevel() {
      bitField0_ &= ~0x00000001;
      level = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 level = 14;</code>
     * @param value the level to set
     * @return this
     */
    public SceneMonsterWaveParam setLevel(final int value) {
      bitField0_ |= 0x00000001;
      level = value;
      return this;
    }

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

    @Override
    public SceneMonsterWaveParam mergeFrom(final SceneMonsterWaveParam other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      return this;
    }

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

    @Override
    public SceneMonsterWaveParam 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 SceneMonsterWaveParam)) {
        return false;
      }
      SceneMonsterWaveParam other = (SceneMonsterWaveParam) o;
      return bitField0_ == other.bitField0_
        && (!hasLevel() || level == other.level);
    }

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

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

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

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

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

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

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

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

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

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

    private enum SceneMonsterWaveParamFactory implements MessageFactory<SceneMonsterWaveParam> {
      INSTANCE;

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

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