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

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

    /**
     * <code>optional .HeroBasicType basic_type = 4;</code>
     */
    private int basicType;

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

    private HeroBasicTypeInfo() {
    }

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

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

    /**
     * <code>optional uint32 rank = 14;</code>
     * @return this
     */
    public HeroBasicTypeInfo clearRank() {
      bitField0_ &= ~0x00000001;
      rank = 0;
      return this;
    }

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

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

    /**
     * <code>optional .HeroBasicType basic_type = 4;</code>
     * @return whether the basicType field is set
     */
    public boolean hasBasicType() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 4;</code>
     * @return this
     */
    public HeroBasicTypeInfo clearBasicType() {
      bitField0_ &= ~0x00000002;
      basicType = 0;
      return this;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 4;</code>
     * @return the basicType
     */
    public HeroBasicTypeOuterClass.HeroBasicType getBasicType() {
      return HeroBasicTypeOuterClass.HeroBasicType.forNumber(basicType);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link HeroBasicTypeInfo#getBasicType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getBasicTypeValue() {
      return basicType;
    }

    /**
     * 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 HeroBasicTypeOuterClass.HeroBasicType}. Setting an invalid value
     * can cause {@link HeroBasicTypeInfo#getBasicType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public HeroBasicTypeInfo setBasicTypeValue(final int value) {
      bitField0_ |= 0x00000002;
      basicType = value;
      return this;
    }

    /**
     * <code>optional .HeroBasicType basic_type = 4;</code>
     * @param value the basicType to set
     * @return this
     */
    public HeroBasicTypeInfo setBasicType(final HeroBasicTypeOuterClass.HeroBasicType value) {
      bitField0_ |= 0x00000002;
      basicType = value.getNumber();
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skill_tree_list = 6;</code>
     * @return whether the skillTreeList field is set
     */
    public boolean hasSkillTreeList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .AvatarSkillTree skill_tree_list = 6;</code>
     * @return this
     */
    public HeroBasicTypeInfo clearSkillTreeList() {
      bitField0_ &= ~0x00000004;
      skillTreeList.clear();
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skill_tree_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 skill_tree_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_ |= 0x00000004;
      return skillTreeList;
    }

    /**
     * <code>repeated .AvatarSkillTree skill_tree_list = 6;</code>
     * @param value the skillTreeList to add
     * @return this
     */
    public HeroBasicTypeInfo addSkillTreeList(
        final AvatarSkillTreeOuterClass.AvatarSkillTree value) {
      bitField0_ |= 0x00000004;
      skillTreeList.add(value);
      return this;
    }

    /**
     * <code>repeated .AvatarSkillTree skill_tree_list = 6;</code>
     * @param values the skillTreeList to add
     * @return this
     */
    public HeroBasicTypeInfo addAllSkillTreeList(
        final AvatarSkillTreeOuterClass.AvatarSkillTree... values) {
      bitField0_ |= 0x00000004;
      skillTreeList.addAll(values);
      return this;
    }

    @Override
    public HeroBasicTypeInfo copyFrom(final HeroBasicTypeInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        rank = other.rank;
        basicType = other.basicType;
        skillTreeList.copyFrom(other.skillTreeList);
      }
      return this;
    }

    @Override
    public HeroBasicTypeInfo mergeFrom(final HeroBasicTypeInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRank()) {
        setRank(other.rank);
      }
      if (other.hasBasicType()) {
        setBasicTypeValue(other.basicType);
      }
      if (other.hasSkillTreeList()) {
        getMutableSkillTreeList().addAll(other.skillTreeList);
      }
      return this;
    }

    @Override
    public HeroBasicTypeInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      rank = 0;
      basicType = 0;
      skillTreeList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof HeroBasicTypeInfo)) {
        return false;
      }
      HeroBasicTypeInfo other = (HeroBasicTypeInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasRank() || rank == other.rank)
        && (!hasBasicType() || basicType == other.basicType)
        && (!hasSkillTreeList() || skillTreeList.equals(other.skillTreeList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(rank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 32);
        output.writeEnumNoTag(basicType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < skillTreeList.length(); i++) {
          output.writeRawByte((byte) 50);
          output.writeMessageNoTag(skillTreeList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(rank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(basicType);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * skillTreeList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(skillTreeList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public HeroBasicTypeInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 112: {
            // rank
            rank = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // basicType
            final int value = input.readInt32();
            if (HeroBasicTypeOuterClass.HeroBasicType.forNumber(value) != null) {
              basicType = value;
              bitField0_ |= 0x00000002;
            }
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // skillTreeList
            tag = input.readRepeatedMessage(skillTreeList, tag);
            bitField0_ |= 0x00000004;
            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.rank, rank);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeEnum(FieldNames.basicType, basicType, HeroBasicTypeOuterClass.HeroBasicType.converter());
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.skillTreeList, skillTreeList);
      }
      output.endObject();
    }

    @Override
    public HeroBasicTypeInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 3492908: {
            if (input.isAtField(FieldNames.rank)) {
              if (!input.trySkipNullValue()) {
                rank = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1699147640:
          case -1123950421: {
            if (input.isAtField(FieldNames.basicType)) {
              if (!input.trySkipNullValue()) {
                final HeroBasicTypeOuterClass.HeroBasicType value = input.readEnum(HeroBasicTypeOuterClass.HeroBasicType.converter());
                if (value != null) {
                  basicType = value.getNumber();
                  bitField0_ |= 0x00000002;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1614407373:
          case 1368677425: {
            if (input.isAtField(FieldNames.skillTreeList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(skillTreeList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum HeroBasicTypeInfoFactory implements MessageFactory<HeroBasicTypeInfo> {
      INSTANCE;

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

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

      static final FieldName basicType = FieldName.forField("basicType", "basic_type");

      static final FieldName skillTreeList = FieldName.forField("skillTreeList", "skill_tree_list");
    }
  }
}
