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

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

    /**
     * <code>optional uint32 index = 14;</code>
     */
    private int index;

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

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

    private BattleRecordAvatar() {
    }

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

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

    /**
     * <code>optional uint32 level = 4;</code>
     * @return this
     */
    public BattleRecordAvatar clearLevel() {
      bitField0_ &= ~0x00000001;
      level = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 index = 14;</code>
     * @return this
     */
    public BattleRecordAvatar clearIndex() {
      bitField0_ &= ~0x00000002;
      index = 0;
      return this;
    }

    /**
     * <code>optional uint32 index = 14;</code>
     * @return the index
     */
    public int getIndex() {
      return index;
    }

    /**
     * <code>optional uint32 index = 14;</code>
     * @param value the index to set
     * @return this
     */
    public BattleRecordAvatar setIndex(final int value) {
      bitField0_ |= 0x00000002;
      index = value;
      return this;
    }

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

    /**
     * <code>optional uint32 id = 15;</code>
     * @return this
     */
    public BattleRecordAvatar clearId() {
      bitField0_ &= ~0x00000004;
      id = 0;
      return this;
    }

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

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

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

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

    /**
     * <code>optional .AvatarType avatar_type = 1;</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 BattleRecordAvatar#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 BattleRecordAvatar#getAvatarType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public BattleRecordAvatar setAvatarTypeValue(final int value) {
      bitField0_ |= 0x00000008;
      avatarType = value;
      return this;
    }

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

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

    @Override
    public BattleRecordAvatar mergeFrom(final BattleRecordAvatar other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasIndex()) {
        setIndex(other.index);
      }
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasAvatarType()) {
        setAvatarTypeValue(other.avatarType);
      }
      return this;
    }

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

    @Override
    public BattleRecordAvatar 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 BattleRecordAvatar)) {
        return false;
      }
      BattleRecordAvatar other = (BattleRecordAvatar) o;
      return bitField0_ == other.bitField0_
        && (!hasLevel() || level == other.level)
        && (!hasIndex() || index == other.index)
        && (!hasId() || id == other.id)
        && (!hasAvatarType() || avatarType == other.avatarType);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(level);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(index);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 8);
        output.writeEnumNoTag(avatarType);
      }
    }

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

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

    @Override
    public BattleRecordAvatar mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 100346066: {
            if (input.isAtField(FieldNames.index)) {
              if (!input.trySkipNullValue()) {
                index = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3355: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } 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_ |= 0x00000008;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleRecordAvatarFactory implements MessageFactory<BattleRecordAvatar> {
      INSTANCE;

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

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

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

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

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