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

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

    /**
     * <code>optional uint32 score = 11;</code>
     */
    private int score;

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 7;</code>
     */
    private final PlayerSimpleInfoOuterClass.PlayerSimpleInfo friendSimpleInfo = PlayerSimpleInfoOuterClass.PlayerSimpleInfo.newInstance();

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</code>
     */
    private final RepeatedMessage<BattleRecordAvatarsOuterClass.BattleRecordAvatars> battleRecordAvatars = RepeatedMessage.newEmptyInstance(BattleRecordAvatarsOuterClass.BattleRecordAvatars.getFactory());

    private FriendChallengeInfo() {
    }

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

    /**
     * <code>optional uint32 battle_record_stars = 8;</code>
     * @return whether the battleRecordStars field is set
     */
    public boolean hasBattleRecordStars() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 battle_record_stars = 8;</code>
     * @return this
     */
    public FriendChallengeInfo clearBattleRecordStars() {
      bitField0_ &= ~0x00000001;
      battleRecordStars = 0;
      return this;
    }

    /**
     * <code>optional uint32 battle_record_stars = 8;</code>
     * @return the battleRecordStars
     */
    public int getBattleRecordStars() {
      return battleRecordStars;
    }

    /**
     * <code>optional uint32 battle_record_stars = 8;</code>
     * @param value the battleRecordStars to set
     * @return this
     */
    public FriendChallengeInfo setBattleRecordStars(final int value) {
      bitField0_ |= 0x00000001;
      battleRecordStars = value;
      return this;
    }

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

    /**
     * <code>optional uint32 score = 11;</code>
     * @return this
     */
    public FriendChallengeInfo clearScore() {
      bitField0_ &= ~0x00000002;
      score = 0;
      return this;
    }

    /**
     * <code>optional uint32 score = 11;</code>
     * @return the score
     */
    public int getScore() {
      return score;
    }

    /**
     * <code>optional uint32 score = 11;</code>
     * @param value the score to set
     * @return this
     */
    public FriendChallengeInfo setScore(final int value) {
      bitField0_ |= 0x00000002;
      score = value;
      return this;
    }

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 7;</code>
     * @return whether the friendSimpleInfo field is set
     */
    public boolean hasFriendSimpleInfo() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 7;</code>
     * @return this
     */
    public FriendChallengeInfo clearFriendSimpleInfo() {
      bitField0_ &= ~0x00000004;
      friendSimpleInfo.clear();
      return this;
    }

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 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 #getMutableFriendSimpleInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public PlayerSimpleInfoOuterClass.PlayerSimpleInfo getFriendSimpleInfo() {
      return friendSimpleInfo;
    }

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 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 PlayerSimpleInfoOuterClass.PlayerSimpleInfo getMutableFriendSimpleInfo() {
      bitField0_ |= 0x00000004;
      return friendSimpleInfo;
    }

    /**
     * <code>optional .PlayerSimpleInfo friend_simple_info = 7;</code>
     * @param value the friendSimpleInfo to set
     * @return this
     */
    public FriendChallengeInfo setFriendSimpleInfo(
        final PlayerSimpleInfoOuterClass.PlayerSimpleInfo value) {
      bitField0_ |= 0x00000004;
      friendSimpleInfo.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</code>
     * @return whether the battleRecordAvatars field is set
     */
    public boolean hasBattleRecordAvatars() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</code>
     * @return this
     */
    public FriendChallengeInfo clearBattleRecordAvatars() {
      bitField0_ &= ~0x00000008;
      battleRecordAvatars.clear();
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</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 #getMutableBattleRecordAvatars()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<BattleRecordAvatarsOuterClass.BattleRecordAvatars> getBattleRecordAvatars(
        ) {
      return battleRecordAvatars;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</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<BattleRecordAvatarsOuterClass.BattleRecordAvatars> getMutableBattleRecordAvatars(
        ) {
      bitField0_ |= 0x00000008;
      return battleRecordAvatars;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</code>
     * @param value the battleRecordAvatars to add
     * @return this
     */
    public FriendChallengeInfo addBattleRecordAvatars(
        final BattleRecordAvatarsOuterClass.BattleRecordAvatars value) {
      bitField0_ |= 0x00000008;
      battleRecordAvatars.add(value);
      return this;
    }

    /**
     * <code>repeated .BattleRecordAvatars battle_record_avatars = 2;</code>
     * @param values the battleRecordAvatars to add
     * @return this
     */
    public FriendChallengeInfo addAllBattleRecordAvatars(
        final BattleRecordAvatarsOuterClass.BattleRecordAvatars... values) {
      bitField0_ |= 0x00000008;
      battleRecordAvatars.addAll(values);
      return this;
    }

    @Override
    public FriendChallengeInfo copyFrom(final FriendChallengeInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        battleRecordStars = other.battleRecordStars;
        score = other.score;
        friendSimpleInfo.copyFrom(other.friendSimpleInfo);
        battleRecordAvatars.copyFrom(other.battleRecordAvatars);
      }
      return this;
    }

    @Override
    public FriendChallengeInfo mergeFrom(final FriendChallengeInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasBattleRecordStars()) {
        setBattleRecordStars(other.battleRecordStars);
      }
      if (other.hasScore()) {
        setScore(other.score);
      }
      if (other.hasFriendSimpleInfo()) {
        getMutableFriendSimpleInfo().mergeFrom(other.friendSimpleInfo);
      }
      if (other.hasBattleRecordAvatars()) {
        getMutableBattleRecordAvatars().addAll(other.battleRecordAvatars);
      }
      return this;
    }

    @Override
    public FriendChallengeInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      battleRecordStars = 0;
      score = 0;
      friendSimpleInfo.clear();
      battleRecordAvatars.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FriendChallengeInfo)) {
        return false;
      }
      FriendChallengeInfo other = (FriendChallengeInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasBattleRecordStars() || battleRecordStars == other.battleRecordStars)
        && (!hasScore() || score == other.score)
        && (!hasFriendSimpleInfo() || friendSimpleInfo.equals(other.friendSimpleInfo))
        && (!hasBattleRecordAvatars() || battleRecordAvatars.equals(other.battleRecordAvatars));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(battleRecordStars);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 88);
        output.writeUInt32NoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 58);
        output.writeMessageNoTag(friendSimpleInfo);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < battleRecordAvatars.length(); i++) {
          output.writeRawByte((byte) 18);
          output.writeMessageNoTag(battleRecordAvatars.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(battleRecordStars);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(friendSimpleInfo);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * battleRecordAvatars.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(battleRecordAvatars);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FriendChallengeInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 64: {
            // battleRecordStars
            battleRecordStars = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 88) {
              break;
            }
          }
          case 88: {
            // score
            score = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 58) {
              break;
            }
          }
          case 58: {
            // friendSimpleInfo
            input.readMessage(friendSimpleInfo);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // battleRecordAvatars
            tag = input.readRepeatedMessage(battleRecordAvatars, tag);
            bitField0_ |= 0x00000008;
            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.battleRecordStars, battleRecordStars);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.score, score);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.friendSimpleInfo, friendSimpleInfo);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedMessage(FieldNames.battleRecordAvatars, battleRecordAvatars);
      }
      output.endObject();
    }

    @Override
    public FriendChallengeInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1025792328:
          case 59201306: {
            if (input.isAtField(FieldNames.battleRecordStars)) {
              if (!input.trySkipNullValue()) {
                battleRecordStars = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 109264530: {
            if (input.isAtField(FieldNames.score)) {
              if (!input.trySkipNullValue()) {
                score = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 983603902:
          case -184903942: {
            if (input.isAtField(FieldNames.friendSimpleInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(friendSimpleInfo);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -976809263:
          case -1974979917: {
            if (input.isAtField(FieldNames.battleRecordAvatars)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(battleRecordAvatars);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FriendChallengeInfoFactory implements MessageFactory<FriendChallengeInfo> {
      INSTANCE;

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

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

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

      static final FieldName friendSimpleInfo = FieldName.forField("friendSimpleInfo", "friend_simple_info");

      static final FieldName battleRecordAvatars = FieldName.forField("battleRecordAvatars", "battle_record_avatars");
    }
  }
}
