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

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

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

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

    private BattleTarget() {
    }

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

    /**
     * <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 BattleTarget 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 BattleTarget setId(final int value) {
      bitField0_ |= 0x00000001;
      id = value;
      return this;
    }

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

    /**
     * <code>optional uint32 progress = 2;</code>
     * @return this
     */
    public BattleTarget clearProgress() {
      bitField0_ &= ~0x00000002;
      progress = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 total_progress = 3;</code>
     * @return this
     */
    public BattleTarget clearTotalProgress() {
      bitField0_ &= ~0x00000004;
      totalProgress = 0;
      return this;
    }

    /**
     * <code>optional uint32 total_progress = 3;</code>
     * @return the totalProgress
     */
    public int getTotalProgress() {
      return totalProgress;
    }

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

    @Override
    public BattleTarget copyFrom(final BattleTarget other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        id = other.id;
        progress = other.progress;
        totalProgress = other.totalProgress;
      }
      return this;
    }

    @Override
    public BattleTarget mergeFrom(final BattleTarget other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasProgress()) {
        setProgress(other.progress);
      }
      if (other.hasTotalProgress()) {
        setTotalProgress(other.totalProgress);
      }
      return this;
    }

    @Override
    public BattleTarget clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      id = 0;
      progress = 0;
      totalProgress = 0;
      return this;
    }

    @Override
    public BattleTarget 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 BattleTarget)) {
        return false;
      }
      BattleTarget other = (BattleTarget) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasProgress() || progress == other.progress)
        && (!hasTotalProgress() || totalProgress == other.totalProgress);
    }

    @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(progress);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(totalProgress);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public BattleTarget 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: {
            // progress
            progress = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // totalProgress
            totalProgress = 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.id, id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.progress, progress);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.totalProgress, totalProgress);
      }
      output.endObject();
    }

    @Override
    public BattleTarget 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 -1001078227: {
            if (input.isAtField(FieldNames.progress)) {
              if (!input.trySkipNullValue()) {
                progress = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -974619247:
          case -2094299960: {
            if (input.isAtField(FieldNames.totalProgress)) {
              if (!input.trySkipNullValue()) {
                totalProgress = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleTargetFactory implements MessageFactory<BattleTarget> {
      INSTANCE;

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

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

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

      static final FieldName totalProgress = FieldName.forField("totalProgress", "total_progress");
    }
  }
}
