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

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

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

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

    /**
     * <code>optional uint32 rank = 4;</code>
     */
    private int rank;

    private BattleEquipment() {
    }

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

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

    /**
     * <code>optional uint32 id = 1;</code>
     * @return this
     */
    public BattleEquipment clearId() {
      bitField0_ &= ~0x00000001;
      id = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 level = 2;</code>
     * @return this
     */
    public BattleEquipment clearLevel() {
      bitField0_ &= ~0x00000002;
      level = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 promotion = 3;</code>
     * @return this
     */
    public BattleEquipment clearPromotion() {
      bitField0_ &= ~0x00000004;
      promotion = 0;
      return this;
    }

    /**
     * <code>optional uint32 promotion = 3;</code>
     * @return the promotion
     */
    public int getPromotion() {
      return promotion;
    }

    /**
     * <code>optional uint32 promotion = 3;</code>
     * @param value the promotion to set
     * @return this
     */
    public BattleEquipment setPromotion(final int value) {
      bitField0_ |= 0x00000004;
      promotion = value;
      return this;
    }

    /**
     * <code>optional uint32 rank = 4;</code>
     * @return whether the rank field is set
     */
    public boolean hasRank() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 rank = 4;</code>
     * @return this
     */
    public BattleEquipment clearRank() {
      bitField0_ &= ~0x00000008;
      rank = 0;
      return this;
    }

    /**
     * <code>optional uint32 rank = 4;</code>
     * @return the rank
     */
    public int getRank() {
      return rank;
    }

    /**
     * <code>optional uint32 rank = 4;</code>
     * @param value the rank to set
     * @return this
     */
    public BattleEquipment setRank(final int value) {
      bitField0_ |= 0x00000008;
      rank = value;
      return this;
    }

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

    @Override
    public BattleEquipment mergeFrom(final BattleEquipment other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasPromotion()) {
        setPromotion(other.promotion);
      }
      if (other.hasRank()) {
        setRank(other.rank);
      }
      return this;
    }

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

    @Override
    public BattleEquipment 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 BattleEquipment)) {
        return false;
      }
      BattleEquipment other = (BattleEquipment) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasLevel() || level == other.level)
        && (!hasPromotion() || promotion == other.promotion)
        && (!hasRank() || rank == other.rank);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(level);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(promotion);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(rank);
      }
    }

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

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

    @Override
    public BattleEquipment mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 3355: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -799212381: {
            if (input.isAtField(FieldNames.promotion)) {
              if (!input.trySkipNullValue()) {
                promotion = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3492908: {
            if (input.isAtField(FieldNames.rank)) {
              if (!input.trySkipNullValue()) {
                rank = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleEquipmentFactory implements MessageFactory<BattleEquipment> {
      INSTANCE;

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

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

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

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

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