// 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.RepeatedInt;
import us.hebi.quickbuf.RepeatedMessage;

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

    /**
     * <code>optional uint64 first_met_timestamp = 15;</code>
     */
    private long firstMetTimestamp;

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

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

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

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

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

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

    /**
     * <code>repeated uint32 taken_rewards = 13;</code>
     */
    private final RepeatedInt takenRewards = RepeatedInt.newEmptyInstance();

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</code>
     */
    private final RepeatedMessage<EquipRelicOuterClass.EquipRelic> equipRelicList = RepeatedMessage.newEmptyInstance(EquipRelicOuterClass.EquipRelic.getFactory());

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

    private Avatar() {
    }

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

    /**
     * <code>optional uint64 first_met_timestamp = 15;</code>
     * @return whether the firstMetTimestamp field is set
     */
    public boolean hasFirstMetTimestamp() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint64 first_met_timestamp = 15;</code>
     * @return this
     */
    public Avatar clearFirstMetTimestamp() {
      bitField0_ &= ~0x00000001;
      firstMetTimestamp = 0L;
      return this;
    }

    /**
     * <code>optional uint64 first_met_timestamp = 15;</code>
     * @return the firstMetTimestamp
     */
    public long getFirstMetTimestamp() {
      return firstMetTimestamp;
    }

    /**
     * <code>optional uint64 first_met_timestamp = 15;</code>
     * @param value the firstMetTimestamp to set
     * @return this
     */
    public Avatar setFirstMetTimestamp(final long value) {
      bitField0_ |= 0x00000001;
      firstMetTimestamp = value;
      return this;
    }

    /**
     * <code>optional uint32 equipment_unique_id = 1;</code>
     * @return whether the equipmentUniqueId field is set
     */
    public boolean hasEquipmentUniqueId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 equipment_unique_id = 1;</code>
     * @return this
     */
    public Avatar clearEquipmentUniqueId() {
      bitField0_ &= ~0x00000002;
      equipmentUniqueId = 0;
      return this;
    }

    /**
     * <code>optional uint32 equipment_unique_id = 1;</code>
     * @return the equipmentUniqueId
     */
    public int getEquipmentUniqueId() {
      return equipmentUniqueId;
    }

    /**
     * <code>optional uint32 equipment_unique_id = 1;</code>
     * @param value the equipmentUniqueId to set
     * @return this
     */
    public Avatar setEquipmentUniqueId(final int value) {
      bitField0_ |= 0x00000002;
      equipmentUniqueId = value;
      return this;
    }

    /**
     * <code>optional uint32 base_avatar_id = 2;</code>
     * @return whether the baseAvatarId field is set
     */
    public boolean hasBaseAvatarId() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 base_avatar_id = 2;</code>
     * @return this
     */
    public Avatar clearBaseAvatarId() {
      bitField0_ &= ~0x00000004;
      baseAvatarId = 0;
      return this;
    }

    /**
     * <code>optional uint32 base_avatar_id = 2;</code>
     * @return the baseAvatarId
     */
    public int getBaseAvatarId() {
      return baseAvatarId;
    }

    /**
     * <code>optional uint32 base_avatar_id = 2;</code>
     * @param value the baseAvatarId to set
     * @return this
     */
    public Avatar setBaseAvatarId(final int value) {
      bitField0_ |= 0x00000004;
      baseAvatarId = value;
      return this;
    }

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

    /**
     * <code>optional uint32 promotion = 5;</code>
     * @return this
     */
    public Avatar clearPromotion() {
      bitField0_ &= ~0x00000008;
      promotion = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 rank = 6;</code>
     * @return this
     */
    public Avatar clearRank() {
      bitField0_ &= ~0x00000010;
      rank = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 level = 7;</code>
     * @return this
     */
    public Avatar clearLevel() {
      bitField0_ &= ~0x00000020;
      level = 0;
      return this;
    }

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

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

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

    /**
     * <code>optional uint32 exp = 14;</code>
     * @return this
     */
    public Avatar clearExp() {
      bitField0_ &= ~0x00000040;
      exp = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 exp = 14;</code>
     * @param value the exp to set
     * @return this
     */
    public Avatar setExp(final int value) {
      bitField0_ |= 0x00000040;
      exp = value;
      return this;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</code>
     * @return whether the takenRewards field is set
     */
    public boolean hasTakenRewards() {
      return (bitField0_ & 0x00000080) != 0;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</code>
     * @return this
     */
    public Avatar clearTakenRewards() {
      bitField0_ &= ~0x00000080;
      takenRewards.clear();
      return this;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</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 #getMutableTakenRewards()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getTakenRewards() {
      return takenRewards;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</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 RepeatedInt getMutableTakenRewards() {
      bitField0_ |= 0x00000080;
      return takenRewards;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</code>
     * @param value the takenRewards to add
     * @return this
     */
    public Avatar addTakenRewards(final int value) {
      bitField0_ |= 0x00000080;
      takenRewards.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 taken_rewards = 13;</code>
     * @param values the takenRewards to add
     * @return this
     */
    public Avatar addAllTakenRewards(final int... values) {
      bitField0_ |= 0x00000080;
      takenRewards.addAll(values);
      return this;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</code>
     * @return whether the equipRelicList field is set
     */
    public boolean hasEquipRelicList() {
      return (bitField0_ & 0x00000100) != 0;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</code>
     * @return this
     */
    public Avatar clearEquipRelicList() {
      bitField0_ &= ~0x00000100;
      equipRelicList.clear();
      return this;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</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 #getMutableEquipRelicList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<EquipRelicOuterClass.EquipRelic> getEquipRelicList() {
      return equipRelicList;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</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<EquipRelicOuterClass.EquipRelic> getMutableEquipRelicList() {
      bitField0_ |= 0x00000100;
      return equipRelicList;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</code>
     * @param value the equipRelicList to add
     * @return this
     */
    public Avatar addEquipRelicList(final EquipRelicOuterClass.EquipRelic value) {
      bitField0_ |= 0x00000100;
      equipRelicList.add(value);
      return this;
    }

    /**
     * <code>repeated .EquipRelic equip_relic_list = 8;</code>
     * @param values the equipRelicList to add
     * @return this
     */
    public Avatar addAllEquipRelicList(final EquipRelicOuterClass.EquipRelic... values) {
      bitField0_ |= 0x00000100;
      equipRelicList.addAll(values);
      return this;
    }

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

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

    /**
     * <code>repeated .AvatarSkillTree skilltree_list = 12;</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 = 12;</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_ |= 0x00000200;
      return skilltreeList;
    }

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

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

    @Override
    public Avatar copyFrom(final Avatar other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        firstMetTimestamp = other.firstMetTimestamp;
        equipmentUniqueId = other.equipmentUniqueId;
        baseAvatarId = other.baseAvatarId;
        promotion = other.promotion;
        rank = other.rank;
        level = other.level;
        exp = other.exp;
        takenRewards.copyFrom(other.takenRewards);
        equipRelicList.copyFrom(other.equipRelicList);
        skilltreeList.copyFrom(other.skilltreeList);
      }
      return this;
    }

    @Override
    public Avatar mergeFrom(final Avatar other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasFirstMetTimestamp()) {
        setFirstMetTimestamp(other.firstMetTimestamp);
      }
      if (other.hasEquipmentUniqueId()) {
        setEquipmentUniqueId(other.equipmentUniqueId);
      }
      if (other.hasBaseAvatarId()) {
        setBaseAvatarId(other.baseAvatarId);
      }
      if (other.hasPromotion()) {
        setPromotion(other.promotion);
      }
      if (other.hasRank()) {
        setRank(other.rank);
      }
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasExp()) {
        setExp(other.exp);
      }
      if (other.hasTakenRewards()) {
        getMutableTakenRewards().addAll(other.takenRewards);
      }
      if (other.hasEquipRelicList()) {
        getMutableEquipRelicList().addAll(other.equipRelicList);
      }
      if (other.hasSkilltreeList()) {
        getMutableSkilltreeList().addAll(other.skilltreeList);
      }
      return this;
    }

    @Override
    public Avatar clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      firstMetTimestamp = 0L;
      equipmentUniqueId = 0;
      baseAvatarId = 0;
      promotion = 0;
      rank = 0;
      level = 0;
      exp = 0;
      takenRewards.clear();
      equipRelicList.clear();
      skilltreeList.clear();
      return this;
    }

    @Override
    public Avatar clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      takenRewards.clear();
      equipRelicList.clearQuick();
      skilltreeList.clearQuick();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof Avatar)) {
        return false;
      }
      Avatar other = (Avatar) o;
      return bitField0_ == other.bitField0_
        && (!hasFirstMetTimestamp() || firstMetTimestamp == other.firstMetTimestamp)
        && (!hasEquipmentUniqueId() || equipmentUniqueId == other.equipmentUniqueId)
        && (!hasBaseAvatarId() || baseAvatarId == other.baseAvatarId)
        && (!hasPromotion() || promotion == other.promotion)
        && (!hasRank() || rank == other.rank)
        && (!hasLevel() || level == other.level)
        && (!hasExp() || exp == other.exp)
        && (!hasTakenRewards() || takenRewards.equals(other.takenRewards))
        && (!hasEquipRelicList() || equipRelicList.equals(other.equipRelicList))
        && (!hasSkilltreeList() || skilltreeList.equals(other.skilltreeList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt64NoTag(firstMetTimestamp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(equipmentUniqueId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(baseAvatarId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(promotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(rank);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 56);
        output.writeUInt32NoTag(level);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(exp);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        for (int i = 0; i < takenRewards.length(); i++) {
          output.writeRawByte((byte) 104);
          output.writeUInt32NoTag(takenRewards.array()[i]);
        }
      }
      if ((bitField0_ & 0x00000100) != 0) {
        for (int i = 0; i < equipRelicList.length(); i++) {
          output.writeRawByte((byte) 66);
          output.writeMessageNoTag(equipRelicList.get(i));
        }
      }
      if ((bitField0_ & 0x00000200) != 0) {
        for (int i = 0; i < skilltreeList.length(); i++) {
          output.writeRawByte((byte) 98);
          output.writeMessageNoTag(skilltreeList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt64SizeNoTag(firstMetTimestamp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(equipmentUniqueId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(baseAvatarId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(promotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(rank);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(level);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(exp);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        size += (1 * takenRewards.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(takenRewards);
      }
      if ((bitField0_ & 0x00000100) != 0) {
        size += (1 * equipRelicList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(equipRelicList);
      }
      if ((bitField0_ & 0x00000200) != 0) {
        size += (1 * skilltreeList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(skilltreeList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public Avatar mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 120: {
            // firstMetTimestamp
            firstMetTimestamp = input.readUInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // equipmentUniqueId
            equipmentUniqueId = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // baseAvatarId
            baseAvatarId = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // promotion
            promotion = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // rank
            rank = input.readUInt32();
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 56) {
              break;
            }
          }
          case 56: {
            // level
            level = input.readUInt32();
            bitField0_ |= 0x00000020;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // exp
            exp = input.readUInt32();
            bitField0_ |= 0x00000040;
            tag = input.readTag();
            if (tag != 106) {
              break;
            }
          }
          case 106: {
            // takenRewards [packed=true]
            input.readPackedUInt32(takenRewards, tag);
            bitField0_ |= 0x00000080;
            tag = input.readTag();
            if (tag != 66) {
              break;
            }
          }
          case 66: {
            // equipRelicList
            tag = input.readRepeatedMessage(equipRelicList, tag);
            bitField0_ |= 0x00000100;
            if (tag != 98) {
              break;
            }
          }
          case 98: {
            // skilltreeList
            tag = input.readRepeatedMessage(skilltreeList, tag);
            bitField0_ |= 0x00000200;
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 104: {
            // takenRewards [packed=false]
            tag = input.readRepeatedUInt32(takenRewards, tag);
            bitField0_ |= 0x00000080;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt64(FieldNames.firstMetTimestamp, firstMetTimestamp);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.equipmentUniqueId, equipmentUniqueId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.baseAvatarId, baseAvatarId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.promotion, promotion);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.rank, rank);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeUInt32(FieldNames.level, level);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeUInt32(FieldNames.exp, exp);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeRepeatedUInt32(FieldNames.takenRewards, takenRewards);
      }
      if ((bitField0_ & 0x00000100) != 0) {
        output.writeRepeatedMessage(FieldNames.equipRelicList, equipRelicList);
      }
      if ((bitField0_ & 0x00000200) != 0) {
        output.writeRepeatedMessage(FieldNames.skilltreeList, skilltreeList);
      }
      output.endObject();
    }

    @Override
    public Avatar mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1893996906:
          case 329864996: {
            if (input.isAtField(FieldNames.firstMetTimestamp)) {
              if (!input.trySkipNullValue()) {
                firstMetTimestamp = input.readUInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1867136902:
          case 760467160: {
            if (input.isAtField(FieldNames.equipmentUniqueId)) {
              if (!input.trySkipNullValue()) {
                equipmentUniqueId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 118022725:
          case -1756826157: {
            if (input.isAtField(FieldNames.baseAvatarId)) {
              if (!input.trySkipNullValue()) {
                baseAvatarId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -799212381: {
            if (input.isAtField(FieldNames.promotion)) {
              if (!input.trySkipNullValue()) {
                promotion = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3492908: {
            if (input.isAtField(FieldNames.rank)) {
              if (!input.trySkipNullValue()) {
                rank = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 100893: {
            if (input.isAtField(FieldNames.exp)) {
              if (!input.trySkipNullValue()) {
                exp = input.readUInt32();
                bitField0_ |= 0x00000040;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -932367267:
          case 500229036: {
            if (input.isAtField(FieldNames.takenRewards)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(takenRewards);
                bitField0_ |= 0x00000080;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1578968161:
          case -795441831: {
            if (input.isAtField(FieldNames.equipRelicList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(equipRelicList);
                bitField0_ |= 0x00000100;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1549763245:
          case 815647086: {
            if (input.isAtField(FieldNames.skilltreeList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(skilltreeList);
                bitField0_ |= 0x00000200;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum AvatarFactory implements MessageFactory<Avatar> {
      INSTANCE;

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

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

      static final FieldName equipmentUniqueId = FieldName.forField("equipmentUniqueId", "equipment_unique_id");

      static final FieldName baseAvatarId = FieldName.forField("baseAvatarId", "base_avatar_id");

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

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

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

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

      static final FieldName takenRewards = FieldName.forField("takenRewards", "taken_rewards");

      static final FieldName equipRelicList = FieldName.forField("equipRelicList", "equip_relic_list");

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