// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.proto;

import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;

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

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

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

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</code>
     */
    private final BattleRecord1OuterClass.BattleRecord1 record1 = BattleRecord1OuterClass.BattleRecord1.newInstance();

    private FriendBattleRecordType1() {
    }

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

    public boolean hasBattleRecord() {
      return (((bitField0_ & 0x00000001)) != 0);
    }

    public FriendBattleRecordType1 clearBattleRecord() {
      if (hasBattleRecord()) {
        clearRecord1();
      }
      return this;
    }

    /**
     * <code>optional uint32 star_cnt = 6;</code>
     * @return whether the starCnt field is set
     */
    public boolean hasStarCnt() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 star_cnt = 6;</code>
     * @return this
     */
    public FriendBattleRecordType1 clearStarCnt() {
      bitField0_ &= ~0x00000002;
      starCnt = 0;
      return this;
    }

    /**
     * <code>optional uint32 star_cnt = 6;</code>
     * @return the starCnt
     */
    public int getStarCnt() {
      return starCnt;
    }

    /**
     * <code>optional uint32 star_cnt = 6;</code>
     * @param value the starCnt to set
     * @return this
     */
    public FriendBattleRecordType1 setStarCnt(final int value) {
      bitField0_ |= 0x00000002;
      starCnt = value;
      return this;
    }

    /**
     * <code>optional uint32 group_id = 11;</code>
     * @return whether the groupId field is set
     */
    public boolean hasGroupId() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 group_id = 11;</code>
     * @return this
     */
    public FriendBattleRecordType1 clearGroupId() {
      bitField0_ &= ~0x00000004;
      groupId = 0;
      return this;
    }

    /**
     * <code>optional uint32 group_id = 11;</code>
     * @return the groupId
     */
    public int getGroupId() {
      return groupId;
    }

    /**
     * <code>optional uint32 group_id = 11;</code>
     * @param value the groupId to set
     * @return this
     */
    public FriendBattleRecordType1 setGroupId(final int value) {
      bitField0_ |= 0x00000004;
      groupId = value;
      return this;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</code>
     * @return whether the record1 field is set
     */
    public boolean hasRecord1() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</code>
     * @return this
     */
    public FriendBattleRecordType1 clearRecord1() {
      bitField0_ &= ~0x00000001;
      record1.clear();
      return this;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</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 #getMutableRecord1()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public BattleRecord1OuterClass.BattleRecord1 getRecord1() {
      return record1;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</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 BattleRecord1OuterClass.BattleRecord1 getMutableRecord1() {
      bitField0_ |= 0x00000001;
      return record1;
    }

    /**
     * <pre>
     *  BattleRecord2 record2 = 1644;
     * </pre>
     *
     * <code>optional .BattleRecord1 record1 = 2026;</code>
     * @param value the record1 to set
     * @return this
     */
    public FriendBattleRecordType1 setRecord1(final BattleRecord1OuterClass.BattleRecord1 value) {
      bitField0_ |= 0x00000001;
      record1.copyFrom(value);
      return this;
    }

    @Override
    public FriendBattleRecordType1 copyFrom(final FriendBattleRecordType1 other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        starCnt = other.starCnt;
        groupId = other.groupId;
        record1.copyFrom(other.record1);
      }
      return this;
    }

    @Override
    public FriendBattleRecordType1 mergeFrom(final FriendBattleRecordType1 other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasStarCnt()) {
        setStarCnt(other.starCnt);
      }
      if (other.hasGroupId()) {
        setGroupId(other.groupId);
      }
      if (other.hasRecord1()) {
        getMutableRecord1().mergeFrom(other.record1);
      }
      return this;
    }

    @Override
    public FriendBattleRecordType1 clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      starCnt = 0;
      groupId = 0;
      record1.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FriendBattleRecordType1)) {
        return false;
      }
      FriendBattleRecordType1 other = (FriendBattleRecordType1) o;
      return bitField0_ == other.bitField0_
        && (!hasStarCnt() || starCnt == other.starCnt)
        && (!hasGroupId() || groupId == other.groupId)
        && (!hasRecord1() || record1.equals(other.record1));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(starCnt);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 88);
        output.writeUInt32NoTag(groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 32466);
        output.writeMessageNoTag(record1);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(starCnt);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeMessageSizeNoTag(record1);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FriendBattleRecordType1 mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 48: {
            // starCnt
            starCnt = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 88) {
              break;
            }
          }
          case 88: {
            // groupId
            groupId = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16210) {
              break;
            }
          }
          case 16210: {
            // record1
            input.readMessage(record1);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.starCnt, starCnt);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.groupId, groupId);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeMessage(FieldNames.record1, record1);
      }
      output.endObject();
    }

    @Override
    public FriendBattleRecordType1 mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1897231945:
          case 1316175356: {
            if (input.isAtField(FieldNames.starCnt)) {
              if (!input.trySkipNullValue()) {
                starCnt = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 293428218:
          case 506361563: {
            if (input.isAtField(FieldNames.groupId)) {
              if (!input.trySkipNullValue()) {
                groupId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1082596864: {
            if (input.isAtField(FieldNames.record1)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(record1);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FriendBattleRecordType1Factory implements MessageFactory<FriendBattleRecordType1> {
      INSTANCE;

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

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

      static final FieldName groupId = FieldName.forField("groupId", "group_id");

      static final FieldName record1 = FieldName.forField("record1");
    }
  }
}
