// 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.RepeatedMessage;

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

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

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

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

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

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

    /**
     * <code>optional uint32 promotion = 10;</code>
     */
    private int promotion;

    /**
     * <code>optional uint32 world_level = 12;</code>
     */
    private int worldLevel;

    /**
     * <code>optional uint32 assist_uid = 13;</code>
     */
    private int assistUid;

    /**
     * <code>optional uint32 avatar_enhance_id = 19;</code>
     */
    private int avatarEnhanceId;

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

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</code>
     */
    private final SpBarInfoOuterClass.SpBarInfo spBar = SpBarInfoOuterClass.SpBarInfo.newInstance();

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 6;</code>
     */
    private final RepeatedMessage<AvatarSkillTreeOuterClass.AvatarSkillTree> skilltreeList = RepeatedMessage.newEmptyInstance(AvatarSkillTreeOuterClass.AvatarSkillTree.getFactory());

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</code>
     */
    private final RepeatedMessage<BattleEquipmentOuterClass.BattleEquipment> equipmentList = RepeatedMessage.newEmptyInstance(BattleEquipmentOuterClass.BattleEquipment.getFactory());

    /**
     * <code>repeated .BattleRelic relic_list = 11;</code>
     */
    private final RepeatedMessage<BattleRelicOuterClass.BattleRelic> relicList = RepeatedMessage.newEmptyInstance(BattleRelicOuterClass.BattleRelic.getFactory());

    private BattleAvatar() {
    }

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

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

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

    /**
     * <code>optional uint32 level = 3;</code>
     * @return this
     */
    public BattleAvatar clearLevel() {
      bitField0_ &= ~0x00000002;
      level = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 rank = 4;</code>
     * @return this
     */
    public BattleAvatar clearRank() {
      bitField0_ &= ~0x00000004;
      rank = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 index = 5;</code>
     * @return this
     */
    public BattleAvatar clearIndex() {
      bitField0_ &= ~0x00000008;
      index = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 hp = 8;</code>
     * @return this
     */
    public BattleAvatar clearHp() {
      bitField0_ &= ~0x00000010;
      hp = 0;
      return this;
    }

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

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

    /**
     * <code>optional uint32 promotion = 10;</code>
     * @return whether the promotion field is set
     */
    public boolean hasPromotion() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional uint32 promotion = 10;</code>
     * @return this
     */
    public BattleAvatar clearPromotion() {
      bitField0_ &= ~0x00000020;
      promotion = 0;
      return this;
    }

    /**
     * <code>optional uint32 promotion = 10;</code>
     * @return the promotion
     */
    public int getPromotion() {
      return promotion;
    }

    /**
     * <code>optional uint32 promotion = 10;</code>
     * @param value the promotion to set
     * @return this
     */
    public BattleAvatar setPromotion(final int value) {
      bitField0_ |= 0x00000020;
      promotion = value;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 12;</code>
     * @return whether the worldLevel field is set
     */
    public boolean hasWorldLevel() {
      return (bitField0_ & 0x00000040) != 0;
    }

    /**
     * <code>optional uint32 world_level = 12;</code>
     * @return this
     */
    public BattleAvatar clearWorldLevel() {
      bitField0_ &= ~0x00000040;
      worldLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 12;</code>
     * @return the worldLevel
     */
    public int getWorldLevel() {
      return worldLevel;
    }

    /**
     * <code>optional uint32 world_level = 12;</code>
     * @param value the worldLevel to set
     * @return this
     */
    public BattleAvatar setWorldLevel(final int value) {
      bitField0_ |= 0x00000040;
      worldLevel = value;
      return this;
    }

    /**
     * <code>optional uint32 assist_uid = 13;</code>
     * @return whether the assistUid field is set
     */
    public boolean hasAssistUid() {
      return (bitField0_ & 0x00000080) != 0;
    }

    /**
     * <code>optional uint32 assist_uid = 13;</code>
     * @return this
     */
    public BattleAvatar clearAssistUid() {
      bitField0_ &= ~0x00000080;
      assistUid = 0;
      return this;
    }

    /**
     * <code>optional uint32 assist_uid = 13;</code>
     * @return the assistUid
     */
    public int getAssistUid() {
      return assistUid;
    }

    /**
     * <code>optional uint32 assist_uid = 13;</code>
     * @param value the assistUid to set
     * @return this
     */
    public BattleAvatar setAssistUid(final int value) {
      bitField0_ |= 0x00000080;
      assistUid = value;
      return this;
    }

    /**
     * <code>optional uint32 avatar_enhance_id = 19;</code>
     * @return whether the avatarEnhanceId field is set
     */
    public boolean hasAvatarEnhanceId() {
      return (bitField0_ & 0x00000100) != 0;
    }

    /**
     * <code>optional uint32 avatar_enhance_id = 19;</code>
     * @return this
     */
    public BattleAvatar clearAvatarEnhanceId() {
      bitField0_ &= ~0x00000100;
      avatarEnhanceId = 0;
      return this;
    }

    /**
     * <code>optional uint32 avatar_enhance_id = 19;</code>
     * @return the avatarEnhanceId
     */
    public int getAvatarEnhanceId() {
      return avatarEnhanceId;
    }

    /**
     * <code>optional uint32 avatar_enhance_id = 19;</code>
     * @param value the avatarEnhanceId to set
     * @return this
     */
    public BattleAvatar setAvatarEnhanceId(final int value) {
      bitField0_ |= 0x00000100;
      avatarEnhanceId = value;
      return this;
    }

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

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

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

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</code>
     * @return whether the spBar field is set
     */
    public boolean hasSpBar() {
      return (bitField0_ & 0x00000400) != 0;
    }

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</code>
     * @return this
     */
    public BattleAvatar clearSpBar() {
      bitField0_ &= ~0x00000400;
      spBar.clear();
      return this;
    }

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</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 #getMutableSpBar()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public SpBarInfoOuterClass.SpBarInfo getSpBar() {
      return spBar;
    }

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</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 SpBarInfoOuterClass.SpBarInfo getMutableSpBar() {
      bitField0_ |= 0x00000400;
      return spBar;
    }

    /**
     * <code>optional .SpBarInfo sp_bar = 16;</code>
     * @param value the spBar to set
     * @return this
     */
    public BattleAvatar setSpBar(final SpBarInfoOuterClass.SpBarInfo value) {
      bitField0_ |= 0x00000400;
      spBar.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 6;</code>
     * @return whether the skilltreeList field is set
     */
    public boolean hasSkilltreeList() {
      return (bitField0_ & 0x00000800) != 0;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 6;</code>
     * @return this
     */
    public BattleAvatar clearSkilltreeList() {
      bitField0_ &= ~0x00000800;
      skilltreeList.clear();
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 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 #getMutableSkilltreeList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<AvatarSkillTreeOuterClass.AvatarSkillTree> getSkilltreeList() {
      return skilltreeList;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 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 RepeatedMessage<AvatarSkillTreeOuterClass.AvatarSkillTree> getMutableSkilltreeList() {
      bitField0_ |= 0x00000800;
      return skilltreeList;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 6;</code>
     * @param value the skilltreeList to add
     * @return this
     */
    public BattleAvatar addSkilltreeList(final AvatarSkillTreeOuterClass.AvatarSkillTree value) {
      bitField0_ |= 0x00000800;
      skilltreeList.add(value);
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 6;</code>
     * @param values the skilltreeList to add
     * @return this
     */
    public BattleAvatar addAllSkilltreeList(
        final AvatarSkillTreeOuterClass.AvatarSkillTree... values) {
      bitField0_ |= 0x00000800;
      skilltreeList.addAll(values);
      return this;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</code>
     * @return whether the equipmentList field is set
     */
    public boolean hasEquipmentList() {
      return (bitField0_ & 0x00001000) != 0;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</code>
     * @return this
     */
    public BattleAvatar clearEquipmentList() {
      bitField0_ &= ~0x00001000;
      equipmentList.clear();
      return this;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</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 #getMutableEquipmentList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<BattleEquipmentOuterClass.BattleEquipment> getEquipmentList() {
      return equipmentList;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</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 RepeatedMessage<BattleEquipmentOuterClass.BattleEquipment> getMutableEquipmentList() {
      bitField0_ |= 0x00001000;
      return equipmentList;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</code>
     * @param value the equipmentList to add
     * @return this
     */
    public BattleAvatar addEquipmentList(final BattleEquipmentOuterClass.BattleEquipment value) {
      bitField0_ |= 0x00001000;
      equipmentList.add(value);
      return this;
    }

    /**
     * <code>repeated .BattleEquipment equipment_list = 7;</code>
     * @param values the equipmentList to add
     * @return this
     */
    public BattleAvatar addAllEquipmentList(
        final BattleEquipmentOuterClass.BattleEquipment... values) {
      bitField0_ |= 0x00001000;
      equipmentList.addAll(values);
      return this;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</code>
     * @return whether the relicList field is set
     */
    public boolean hasRelicList() {
      return (bitField0_ & 0x00002000) != 0;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</code>
     * @return this
     */
    public BattleAvatar clearRelicList() {
      bitField0_ &= ~0x00002000;
      relicList.clear();
      return this;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</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 #getMutableRelicList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<BattleRelicOuterClass.BattleRelic> getRelicList() {
      return relicList;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</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 RepeatedMessage<BattleRelicOuterClass.BattleRelic> getMutableRelicList() {
      bitField0_ |= 0x00002000;
      return relicList;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</code>
     * @param value the relicList to add
     * @return this
     */
    public BattleAvatar addRelicList(final BattleRelicOuterClass.BattleRelic value) {
      bitField0_ |= 0x00002000;
      relicList.add(value);
      return this;
    }

    /**
     * <code>repeated .BattleRelic relic_list = 11;</code>
     * @param values the relicList to add
     * @return this
     */
    public BattleAvatar addAllRelicList(final BattleRelicOuterClass.BattleRelic... values) {
      bitField0_ |= 0x00002000;
      relicList.addAll(values);
      return this;
    }

    @Override
    public BattleAvatar copyFrom(final BattleAvatar other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        id = other.id;
        level = other.level;
        rank = other.rank;
        index = other.index;
        hp = other.hp;
        promotion = other.promotion;
        worldLevel = other.worldLevel;
        assistUid = other.assistUid;
        avatarEnhanceId = other.avatarEnhanceId;
        avatarType = other.avatarType;
        spBar.copyFrom(other.spBar);
        skilltreeList.copyFrom(other.skilltreeList);
        equipmentList.copyFrom(other.equipmentList);
        relicList.copyFrom(other.relicList);
      }
      return this;
    }

    @Override
    public BattleAvatar mergeFrom(final BattleAvatar other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasRank()) {
        setRank(other.rank);
      }
      if (other.hasIndex()) {
        setIndex(other.index);
      }
      if (other.hasHp()) {
        setHp(other.hp);
      }
      if (other.hasPromotion()) {
        setPromotion(other.promotion);
      }
      if (other.hasWorldLevel()) {
        setWorldLevel(other.worldLevel);
      }
      if (other.hasAssistUid()) {
        setAssistUid(other.assistUid);
      }
      if (other.hasAvatarEnhanceId()) {
        setAvatarEnhanceId(other.avatarEnhanceId);
      }
      if (other.hasAvatarType()) {
        setAvatarTypeValue(other.avatarType);
      }
      if (other.hasSpBar()) {
        getMutableSpBar().mergeFrom(other.spBar);
      }
      if (other.hasSkilltreeList()) {
        getMutableSkilltreeList().addAll(other.skilltreeList);
      }
      if (other.hasEquipmentList()) {
        getMutableEquipmentList().addAll(other.equipmentList);
      }
      if (other.hasRelicList()) {
        getMutableRelicList().addAll(other.relicList);
      }
      return this;
    }

    @Override
    public BattleAvatar clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      id = 0;
      level = 0;
      rank = 0;
      index = 0;
      hp = 0;
      promotion = 0;
      worldLevel = 0;
      assistUid = 0;
      avatarEnhanceId = 0;
      avatarType = 0;
      spBar.clear();
      skilltreeList.clear();
      equipmentList.clear();
      relicList.clear();
      return this;
    }

    @Override
    public BattleAvatar clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      spBar.clearQuick();
      skilltreeList.clearQuick();
      equipmentList.clearQuick();
      relicList.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof BattleAvatar)) {
        return false;
      }
      BattleAvatar other = (BattleAvatar) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasLevel() || level == other.level)
        && (!hasRank() || rank == other.rank)
        && (!hasIndex() || index == other.index)
        && (!hasHp() || hp == other.hp)
        && (!hasPromotion() || promotion == other.promotion)
        && (!hasWorldLevel() || worldLevel == other.worldLevel)
        && (!hasAssistUid() || assistUid == other.assistUid)
        && (!hasAvatarEnhanceId() || avatarEnhanceId == other.avatarEnhanceId)
        && (!hasAvatarType() || avatarType == other.avatarType)
        && (!hasSpBar() || spBar.equals(other.spBar))
        && (!hasSkilltreeList() || skilltreeList.equals(other.skilltreeList))
        && (!hasEquipmentList() || equipmentList.equals(other.equipmentList))
        && (!hasRelicList() || relicList.equals(other.relicList));
    }

    @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(level);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(rank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(index);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(hp);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 80);
        output.writeUInt32NoTag(promotion);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeRawByte((byte) 104);
        output.writeUInt32NoTag(assistUid);
      }
      if ((bitField0_ & 0x00000100) != 0) {
        output.writeRawLittleEndian16((short) 408);
        output.writeUInt32NoTag(avatarEnhanceId);
      }
      if ((bitField0_ & 0x00000200) != 0) {
        output.writeRawByte((byte) 8);
        output.writeEnumNoTag(avatarType);
      }
      if ((bitField0_ & 0x00000400) != 0) {
        output.writeRawLittleEndian16((short) 386);
        output.writeMessageNoTag(spBar);
      }
      if ((bitField0_ & 0x00000800) != 0) {
        for (int i = 0; i < skilltreeList.length(); i++) {
          output.writeRawByte((byte) 50);
          output.writeMessageNoTag(skilltreeList.get(i));
        }
      }
      if ((bitField0_ & 0x00001000) != 0) {
        for (int i = 0; i < equipmentList.length(); i++) {
          output.writeRawByte((byte) 58);
          output.writeMessageNoTag(equipmentList.get(i));
        }
      }
      if ((bitField0_ & 0x00002000) != 0) {
        for (int i = 0; i < relicList.length(); i++) {
          output.writeRawByte((byte) 90);
          output.writeMessageNoTag(relicList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(level);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(rank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(index);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(hp);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(promotion);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(assistUid);
      }
      if ((bitField0_ & 0x00000100) != 0) {
        size += 2 + ProtoSink.computeUInt32SizeNoTag(avatarEnhanceId);
      }
      if ((bitField0_ & 0x00000200) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(avatarType);
      }
      if ((bitField0_ & 0x00000400) != 0) {
        size += 2 + ProtoSink.computeMessageSizeNoTag(spBar);
      }
      if ((bitField0_ & 0x00000800) != 0) {
        size += (1 * skilltreeList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(skilltreeList);
      }
      if ((bitField0_ & 0x00001000) != 0) {
        size += (1 * equipmentList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(equipmentList);
      }
      if ((bitField0_ & 0x00002000) != 0) {
        size += (1 * relicList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(relicList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public BattleAvatar 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: {
            // level
            level = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // rank
            rank = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // index
            index = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // hp
            hp = input.readUInt32();
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 80) {
              break;
            }
          }
          case 80: {
            // promotion
            promotion = input.readUInt32();
            bitField0_ |= 0x00000020;
            tag = input.readTag();
            if (tag != 96) {
              break;
            }
          }
          case 96: {
            // worldLevel
            worldLevel = input.readUInt32();
            bitField0_ |= 0x00000040;
            tag = input.readTag();
            if (tag != 104) {
              break;
            }
          }
          case 104: {
            // assistUid
            assistUid = input.readUInt32();
            bitField0_ |= 0x00000080;
            tag = input.readTag();
            if (tag != 152) {
              break;
            }
          }
          case 152: {
            // avatarEnhanceId
            avatarEnhanceId = input.readUInt32();
            bitField0_ |= 0x00000100;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // avatarType
            final int value = input.readInt32();
            if (AvatarTypeOuterClass.AvatarType.forNumber(value) != null) {
              avatarType = value;
              bitField0_ |= 0x00000200;
            }
            tag = input.readTag();
            if (tag != 130) {
              break;
            }
          }
          case 130: {
            // spBar
            input.readMessage(spBar);
            bitField0_ |= 0x00000400;
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // skilltreeList
            tag = input.readRepeatedMessage(skilltreeList, tag);
            bitField0_ |= 0x00000800;
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // equipmentList
            tag = input.readRepeatedMessage(equipmentList, tag);
            bitField0_ |= 0x00001000;
            if (tag != 90) {
              break;
            }
          }
          case 90: {
            // relicList
            tag = input.readRepeatedMessage(relicList, tag);
            bitField0_ |= 0x00002000;
            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.level, level);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.rank, rank);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.index, index);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.hp, hp);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeUInt32(FieldNames.promotion, promotion);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeUInt32(FieldNames.worldLevel, worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeUInt32(FieldNames.assistUid, assistUid);
      }
      if ((bitField0_ & 0x00000100) != 0) {
        output.writeUInt32(FieldNames.avatarEnhanceId, avatarEnhanceId);
      }
      if ((bitField0_ & 0x00000200) != 0) {
        output.writeEnum(FieldNames.avatarType, avatarType, AvatarTypeOuterClass.AvatarType.converter());
      }
      if ((bitField0_ & 0x00000400) != 0) {
        output.writeMessage(FieldNames.spBar, spBar);
      }
      if ((bitField0_ & 0x00000800) != 0) {
        output.writeRepeatedMessage(FieldNames.skilltreeList, skilltreeList);
      }
      if ((bitField0_ & 0x00001000) != 0) {
        output.writeRepeatedMessage(FieldNames.equipmentList, equipmentList);
      }
      if ((bitField0_ & 0x00002000) != 0) {
        output.writeRepeatedMessage(FieldNames.relicList, relicList);
      }
      output.endObject();
    }

    @Override
    public BattleAvatar 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 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3492908: {
            if (input.isAtField(FieldNames.rank)) {
              if (!input.trySkipNullValue()) {
                rank = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 100346066: {
            if (input.isAtField(FieldNames.index)) {
              if (!input.trySkipNullValue()) {
                index = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3336: {
            if (input.isAtField(FieldNames.hp)) {
              if (!input.trySkipNullValue()) {
                hp = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -799212381: {
            if (input.isAtField(FieldNames.promotion)) {
              if (!input.trySkipNullValue()) {
                promotion = input.readUInt32();
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 440007442:
          case 1305257111: {
            if (input.isAtField(FieldNames.worldLevel)) {
              if (!input.trySkipNullValue()) {
                worldLevel = input.readUInt32();
                bitField0_ |= 0x00000040;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1429816615:
          case 1374951802: {
            if (input.isAtField(FieldNames.assistUid)) {
              if (!input.trySkipNullValue()) {
                assistUid = input.readUInt32();
                bitField0_ |= 0x00000080;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -94590192:
          case 306903794: {
            if (input.isAtField(FieldNames.avatarEnhanceId)) {
              if (!input.trySkipNullValue()) {
                avatarEnhanceId = input.readUInt32();
                bitField0_ |= 0x00000100;
              }
            } 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_ |= 0x00000200;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 109608054:
          case -896253135: {
            if (input.isAtField(FieldNames.spBar)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(spBar);
                bitField0_ |= 0x00000400;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1549763245:
          case 815647086: {
            if (input.isAtField(FieldNames.skilltreeList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(skilltreeList);
                bitField0_ |= 0x00000800;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2007143244:
          case 2109525167: {
            if (input.isAtField(FieldNames.equipmentList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(equipmentList);
                bitField0_ |= 0x00001000;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 204814001:
          case 2071893482: {
            if (input.isAtField(FieldNames.relicList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(relicList);
                bitField0_ |= 0x00002000;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleAvatarFactory implements MessageFactory<BattleAvatar> {
      INSTANCE;

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

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

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

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

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

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

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

      static final FieldName worldLevel = FieldName.forField("worldLevel", "world_level");

      static final FieldName assistUid = FieldName.forField("assistUid", "assist_uid");

      static final FieldName avatarEnhanceId = FieldName.forField("avatarEnhanceId", "avatar_enhance_id");

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

      static final FieldName spBar = FieldName.forField("spBar", "sp_bar");

      static final FieldName skilltreeList = FieldName.forField("skilltreeList", "skilltree_list");

      static final FieldName equipmentList = FieldName.forField("equipmentList", "equipment_list");

      static final FieldName relicList = FieldName.forField("relicList", "relic_list");
    }
  }
}
