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

    /**
     * <code>optional uint32 cur_sp = 1;</code>
     */
    private int curSp;

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

    private SpBarInfo() {
    }

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

    /**
     * <code>optional uint32 cur_sp = 1;</code>
     * @return whether the curSp field is set
     */
    public boolean hasCurSp() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 cur_sp = 1;</code>
     * @return this
     */
    public SpBarInfo clearCurSp() {
      bitField0_ &= ~0x00000001;
      curSp = 0;
      return this;
    }

    /**
     * <code>optional uint32 cur_sp = 1;</code>
     * @return the curSp
     */
    public int getCurSp() {
      return curSp;
    }

    /**
     * <code>optional uint32 cur_sp = 1;</code>
     * @param value the curSp to set
     * @return this
     */
    public SpBarInfo setCurSp(final int value) {
      bitField0_ |= 0x00000001;
      curSp = value;
      return this;
    }

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

    /**
     * <code>optional uint32 max_sp = 2;</code>
     * @return this
     */
    public SpBarInfo clearMaxSp() {
      bitField0_ &= ~0x00000002;
      maxSp = 0;
      return this;
    }

    /**
     * <code>optional uint32 max_sp = 2;</code>
     * @return the maxSp
     */
    public int getMaxSp() {
      return maxSp;
    }

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

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

    @Override
    public SpBarInfo mergeFrom(final SpBarInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasCurSp()) {
        setCurSp(other.curSp);
      }
      if (other.hasMaxSp()) {
        setMaxSp(other.maxSp);
      }
      return this;
    }

    @Override
    public SpBarInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      curSp = 0;
      maxSp = 0;
      return this;
    }

    @Override
    public SpBarInfo 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 SpBarInfo)) {
        return false;
      }
      SpBarInfo other = (SpBarInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasCurSp() || curSp == other.curSp)
        && (!hasMaxSp() || maxSp == other.maxSp);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(curSp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(maxSp);
      }
    }

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

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

    @Override
    public SpBarInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 95026365:
          case -1349138244: {
            if (input.isAtField(FieldNames.curSp)) {
              if (!input.trySkipNullValue()) {
                curSp = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 103671521:
          case -1081138408: {
            if (input.isAtField(FieldNames.maxSp)) {
              if (!input.trySkipNullValue()) {
                maxSp = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SpBarInfoFactory implements MessageFactory<SpBarInfo> {
      INSTANCE;

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

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

      static final FieldName maxSp = FieldName.forField("maxSp", "max_sp");
    }
  }
}
