// 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;
import us.hebi.quickbuf.ProtoUtil;

public final class BattleSkillInfoOuterClass {
  /**
   * Protobuf type {@code BattleSkillInfo}
   */
  public static final class BattleSkillInfo extends ProtoMessage<BattleSkillInfo> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional double damage = 4;</code>
     */
    private double damage;

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

    private BattleSkillInfo() {
    }

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

    /**
     * <code>optional double damage = 4;</code>
     * @return whether the damage field is set
     */
    public boolean hasDamage() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional double damage = 4;</code>
     * @return this
     */
    public BattleSkillInfo clearDamage() {
      bitField0_ &= ~0x00000001;
      damage = 0D;
      return this;
    }

    /**
     * <code>optional double damage = 4;</code>
     * @return the damage
     */
    public double getDamage() {
      return damage;
    }

    /**
     * <code>optional double damage = 4;</code>
     * @param value the damage to set
     * @return this
     */
    public BattleSkillInfo setDamage(final double value) {
      bitField0_ |= 0x00000001;
      damage = value;
      return this;
    }

    /**
     * <code>optional uint32 skill_id = 1;</code>
     * @return whether the skillId field is set
     */
    public boolean hasSkillId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 skill_id = 1;</code>
     * @return this
     */
    public BattleSkillInfo clearSkillId() {
      bitField0_ &= ~0x00000002;
      skillId = 0;
      return this;
    }

    /**
     * <code>optional uint32 skill_id = 1;</code>
     * @return the skillId
     */
    public int getSkillId() {
      return skillId;
    }

    /**
     * <code>optional uint32 skill_id = 1;</code>
     * @param value the skillId to set
     * @return this
     */
    public BattleSkillInfo setSkillId(final int value) {
      bitField0_ |= 0x00000002;
      skillId = value;
      return this;
    }

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

    @Override
    public BattleSkillInfo mergeFrom(final BattleSkillInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasDamage()) {
        setDamage(other.damage);
      }
      if (other.hasSkillId()) {
        setSkillId(other.skillId);
      }
      return this;
    }

    @Override
    public BattleSkillInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      damage = 0D;
      skillId = 0;
      return this;
    }

    @Override
    public BattleSkillInfo 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 BattleSkillInfo)) {
        return false;
      }
      BattleSkillInfo other = (BattleSkillInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasDamage() || ProtoUtil.isEqual(damage, other.damage))
        && (!hasSkillId() || skillId == other.skillId);
    }

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

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

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

    @Override
    public BattleSkillInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1339126929: {
            if (input.isAtField(FieldNames.damage)) {
              if (!input.trySkipNullValue()) {
                damage = input.readDouble();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2147320652:
          case 2142452169: {
            if (input.isAtField(FieldNames.skillId)) {
              if (!input.trySkipNullValue()) {
                skillId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleSkillInfoFactory implements MessageFactory<BattleSkillInfo> {
      INSTANCE;

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

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

      static final FieldName skillId = FieldName.forField("skillId", "skill_id");
    }
  }
}
