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

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

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

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

    /**
     * <code>optional uint32 avatar_promotion = 5;</code>
     */
    private int avatarPromotion;

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

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     */
    private final AvatarPropertyOuterClass.AvatarProperty avatarStatus = AvatarPropertyOuterClass.AvatarProperty.newInstance();

    private AvatarBattleInfo() {
    }

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

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

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

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

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

    /**
     * <code>optional uint32 avatar_level = 3;</code>
     * @return whether the avatarLevel field is set
     */
    public boolean hasAvatarLevel() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 avatar_level = 3;</code>
     * @return this
     */
    public AvatarBattleInfo clearAvatarLevel() {
      bitField0_ &= ~0x00000002;
      avatarLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 avatar_level = 3;</code>
     * @return the avatarLevel
     */
    public int getAvatarLevel() {
      return avatarLevel;
    }

    /**
     * <code>optional uint32 avatar_level = 3;</code>
     * @param value the avatarLevel to set
     * @return this
     */
    public AvatarBattleInfo setAvatarLevel(final int value) {
      bitField0_ |= 0x00000002;
      avatarLevel = value;
      return this;
    }

    /**
     * <code>optional uint32 avatar_rank = 4;</code>
     * @return whether the avatarRank field is set
     */
    public boolean hasAvatarRank() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 avatar_rank = 4;</code>
     * @return this
     */
    public AvatarBattleInfo clearAvatarRank() {
      bitField0_ &= ~0x00000004;
      avatarRank = 0;
      return this;
    }

    /**
     * <code>optional uint32 avatar_rank = 4;</code>
     * @return the avatarRank
     */
    public int getAvatarRank() {
      return avatarRank;
    }

    /**
     * <code>optional uint32 avatar_rank = 4;</code>
     * @param value the avatarRank to set
     * @return this
     */
    public AvatarBattleInfo setAvatarRank(final int value) {
      bitField0_ |= 0x00000004;
      avatarRank = value;
      return this;
    }

    /**
     * <code>optional uint32 avatar_promotion = 5;</code>
     * @return whether the avatarPromotion field is set
     */
    public boolean hasAvatarPromotion() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 avatar_promotion = 5;</code>
     * @return this
     */
    public AvatarBattleInfo clearAvatarPromotion() {
      bitField0_ &= ~0x00000008;
      avatarPromotion = 0;
      return this;
    }

    /**
     * <code>optional uint32 avatar_promotion = 5;</code>
     * @return the avatarPromotion
     */
    public int getAvatarPromotion() {
      return avatarPromotion;
    }

    /**
     * <code>optional uint32 avatar_promotion = 5;</code>
     * @param value the avatarPromotion to set
     * @return this
     */
    public AvatarBattleInfo setAvatarPromotion(final int value) {
      bitField0_ |= 0x00000008;
      avatarPromotion = value;
      return this;
    }

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

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

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

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     * @return whether the avatarStatus field is set
     */
    public boolean hasAvatarStatus() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     * @return this
     */
    public AvatarBattleInfo clearAvatarStatus() {
      bitField0_ &= ~0x00000020;
      avatarStatus.clear();
      return this;
    }

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableAvatarStatus()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public AvatarPropertyOuterClass.AvatarProperty getAvatarStatus() {
      return avatarStatus;
    }

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public AvatarPropertyOuterClass.AvatarProperty getMutableAvatarStatus() {
      bitField0_ |= 0x00000020;
      return avatarStatus;
    }

    /**
     * <code>optional .AvatarProperty avatar_status = 6;</code>
     * @param value the avatarStatus to set
     * @return this
     */
    public AvatarBattleInfo setAvatarStatus(final AvatarPropertyOuterClass.AvatarProperty value) {
      bitField0_ |= 0x00000020;
      avatarStatus.copyFrom(value);
      return this;
    }

    @Override
    public AvatarBattleInfo copyFrom(final AvatarBattleInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        id = other.id;
        avatarLevel = other.avatarLevel;
        avatarRank = other.avatarRank;
        avatarPromotion = other.avatarPromotion;
        avatarType = other.avatarType;
        avatarStatus.copyFrom(other.avatarStatus);
      }
      return this;
    }

    @Override
    public AvatarBattleInfo mergeFrom(final AvatarBattleInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasAvatarLevel()) {
        setAvatarLevel(other.avatarLevel);
      }
      if (other.hasAvatarRank()) {
        setAvatarRank(other.avatarRank);
      }
      if (other.hasAvatarPromotion()) {
        setAvatarPromotion(other.avatarPromotion);
      }
      if (other.hasAvatarType()) {
        setAvatarTypeValue(other.avatarType);
      }
      if (other.hasAvatarStatus()) {
        getMutableAvatarStatus().mergeFrom(other.avatarStatus);
      }
      return this;
    }

    @Override
    public AvatarBattleInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      id = 0;
      avatarLevel = 0;
      avatarRank = 0;
      avatarPromotion = 0;
      avatarType = 0;
      avatarStatus.clear();
      return this;
    }

    @Override
    public AvatarBattleInfo clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      avatarStatus.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof AvatarBattleInfo)) {
        return false;
      }
      AvatarBattleInfo other = (AvatarBattleInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasAvatarLevel() || avatarLevel == other.avatarLevel)
        && (!hasAvatarRank() || avatarRank == other.avatarRank)
        && (!hasAvatarPromotion() || avatarPromotion == other.avatarPromotion)
        && (!hasAvatarType() || avatarType == other.avatarType)
        && (!hasAvatarStatus() || avatarStatus.equals(other.avatarStatus));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(avatarLevel);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(avatarRank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(avatarPromotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 8);
        output.writeEnumNoTag(avatarType);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 50);
        output.writeMessageNoTag(avatarStatus);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(avatarLevel);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(avatarRank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(avatarPromotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(avatarType);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(avatarStatus);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public AvatarBattleInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // id
            id = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // avatarLevel
            avatarLevel = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // avatarRank
            avatarRank = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // avatarPromotion
            avatarPromotion = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // avatarType
            final int value = input.readInt32();
            if (AvatarTypeOuterClass.AvatarType.forNumber(value) != null) {
              avatarType = value;
              bitField0_ |= 0x00000010;
            }
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // avatarStatus
            input.readMessage(avatarStatus);
            bitField0_ |= 0x00000020;
            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.avatarLevel, avatarLevel);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.avatarRank, avatarRank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.avatarPromotion, avatarPromotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeEnum(FieldNames.avatarType, avatarType, AvatarTypeOuterClass.AvatarType.converter());
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeMessage(FieldNames.avatarStatus, avatarStatus);
      }
      output.endObject();
    }

    @Override
    public AvatarBattleInfo 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 379312555:
          case -576284386: {
            if (input.isAtField(FieldNames.avatarLevel)) {
              if (!input.trySkipNullValue()) {
                avatarLevel = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -403231451:
          case 397226834: {
            if (input.isAtField(FieldNames.avatarRank)) {
              if (!input.trySkipNullValue()) {
                avatarRank = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2142097226:
          case 999660861: {
            if (input.isAtField(FieldNames.avatarPromotion)) {
              if (!input.trySkipNullValue()) {
                avatarPromotion = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } 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_ |= 0x00000010;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -912566613:
          case -471300712: {
            if (input.isAtField(FieldNames.avatarStatus)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(avatarStatus);
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum AvatarBattleInfoFactory implements MessageFactory<AvatarBattleInfo> {
      INSTANCE;

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

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

      static final FieldName avatarLevel = FieldName.forField("avatarLevel", "avatar_level");

      static final FieldName avatarRank = FieldName.forField("avatarRank", "avatar_rank");

      static final FieldName avatarPromotion = FieldName.forField("avatarPromotion", "avatar_promotion");

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

      static final FieldName avatarStatus = FieldName.forField("avatarStatus", "avatar_status");
    }
  }
}
