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

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

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

    /**
     * <code>optional .AvatarType avatar_type = 9;</code>
     */
    private int avatarType;

    private LineupAvatarData() {
    }

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

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

    /**
     * <code>optional uint32 hp = 2;</code>
     * @return this
     */
    public LineupAvatarData clearHp() {
      bitField0_ &= ~0x00000001;
      hp = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 hp = 2;</code>
     * @param value the hp to set
     * @return this
     */
    public LineupAvatarData setHp(final int value) {
      bitField0_ |= 0x00000001;
      hp = value;
      return this;
    }

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

    /**
     * <code>optional uint32 id = 6;</code>
     * @return this
     */
    public LineupAvatarData clearId() {
      bitField0_ &= ~0x00000002;
      id = 0;
      return this;
    }

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

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

    /**
     * <code>optional .AvatarType avatar_type = 9;</code>
     * @return whether the avatarType field is set
     */
    public boolean hasAvatarType() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .AvatarType avatar_type = 9;</code>
     * @return this
     */
    public LineupAvatarData clearAvatarType() {
      bitField0_ &= ~0x00000004;
      avatarType = 0;
      return this;
    }

    /**
     * <code>optional .AvatarType avatar_type = 9;</code>
     * @return the avatarType
     */
    public AvatarTypeOuterClass.AvatarType getAvatarType() {
      return AvatarTypeOuterClass.AvatarType.forNumber(avatarType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link LineupAvatarData#getAvatarType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getAvatarTypeValue() {
      return avatarType;
    }

    /**
     * Sets the value of the internal enum store. This does not
     * do any validity checks, so be sure to use appropriate value
     * constants from {@link AvatarTypeOuterClass.AvatarType}. Setting an invalid value
     * can cause {@link LineupAvatarData#getAvatarType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public LineupAvatarData setAvatarTypeValue(final int value) {
      bitField0_ |= 0x00000004;
      avatarType = value;
      return this;
    }

    /**
     * <code>optional .AvatarType avatar_type = 9;</code>
     * @param value the avatarType to set
     * @return this
     */
    public LineupAvatarData setAvatarType(final AvatarTypeOuterClass.AvatarType value) {
      bitField0_ |= 0x00000004;
      avatarType = value.getNumber();
      return this;
    }

    @Override
    public LineupAvatarData copyFrom(final LineupAvatarData other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        hp = other.hp;
        id = other.id;
        avatarType = other.avatarType;
      }
      return this;
    }

    @Override
    public LineupAvatarData mergeFrom(final LineupAvatarData other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasHp()) {
        setHp(other.hp);
      }
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasAvatarType()) {
        setAvatarTypeValue(other.avatarType);
      }
      return this;
    }

    @Override
    public LineupAvatarData clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      hp = 0;
      id = 0;
      avatarType = 0;
      return this;
    }

    @Override
    public LineupAvatarData 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 LineupAvatarData)) {
        return false;
      }
      LineupAvatarData other = (LineupAvatarData) o;
      return bitField0_ == other.bitField0_
        && (!hasHp() || hp == other.hp)
        && (!hasId() || id == other.id)
        && (!hasAvatarType() || avatarType == other.avatarType);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(hp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 72);
        output.writeEnumNoTag(avatarType);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public LineupAvatarData mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // hp
            hp = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // id
            id = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 72) {
              break;
            }
          }
          case 72: {
            // avatarType
            final int value = input.readInt32();
            if (AvatarTypeOuterClass.AvatarType.forNumber(value) != null) {
              avatarType = value;
              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.hp, hp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.id, id);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeEnum(FieldNames.avatarType, avatarType, AvatarTypeOuterClass.AvatarType.converter());
      }
      output.endObject();
    }

    @Override
    public LineupAvatarData mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 3336: {
            if (input.isAtField(FieldNames.hp)) {
              if (!input.trySkipNullValue()) {
                hp = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3355: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -403148749:
          case 397309536: {
            if (input.isAtField(FieldNames.avatarType)) {
              if (!input.trySkipNullValue()) {
                final AvatarTypeOuterClass.AvatarType value = input.readEnum(AvatarTypeOuterClass.AvatarType.converter());
                if (value != null) {
                  avatarType = value.getNumber();
                  bitField0_ |= 0x00000004;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum LineupAvatarDataFactory implements MessageFactory<LineupAvatarData> {
      INSTANCE;

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

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

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

      static final FieldName avatarType = FieldName.forField("avatarType", "avatar_type");
    }
  }
}
