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

    /**
     * <code>optional uint32 record_id = 9;</code>
     */
    private int recordId;

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</code>
     */
    private final BattleRecord1InfoOuterClass.BattleRecord1Info recordInfo = BattleRecord1InfoOuterClass.BattleRecord1Info.newInstance();

    private BattleRecord1() {
    }

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

    /**
     * <code>optional uint32 record_id = 9;</code>
     * @return whether the recordId field is set
     */
    public boolean hasRecordId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 record_id = 9;</code>
     * @return this
     */
    public BattleRecord1 clearRecordId() {
      bitField0_ &= ~0x00000001;
      recordId = 0;
      return this;
    }

    /**
     * <code>optional uint32 record_id = 9;</code>
     * @return the recordId
     */
    public int getRecordId() {
      return recordId;
    }

    /**
     * <code>optional uint32 record_id = 9;</code>
     * @param value the recordId to set
     * @return this
     */
    public BattleRecord1 setRecordId(final int value) {
      bitField0_ |= 0x00000001;
      recordId = value;
      return this;
    }

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</code>
     * @return whether the recordInfo field is set
     */
    public boolean hasRecordInfo() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</code>
     * @return this
     */
    public BattleRecord1 clearRecordInfo() {
      bitField0_ &= ~0x00000002;
      recordInfo.clear();
      return this;
    }

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</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 #getMutableRecordInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public BattleRecord1InfoOuterClass.BattleRecord1Info getRecordInfo() {
      return recordInfo;
    }

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</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 BattleRecord1InfoOuterClass.BattleRecord1Info getMutableRecordInfo() {
      bitField0_ |= 0x00000002;
      return recordInfo;
    }

    /**
     * <code>optional .BattleRecord1Info record_info = 1;</code>
     * @param value the recordInfo to set
     * @return this
     */
    public BattleRecord1 setRecordInfo(final BattleRecord1InfoOuterClass.BattleRecord1Info value) {
      bitField0_ |= 0x00000002;
      recordInfo.copyFrom(value);
      return this;
    }

    @Override
    public BattleRecord1 copyFrom(final BattleRecord1 other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        recordId = other.recordId;
        recordInfo.copyFrom(other.recordInfo);
      }
      return this;
    }

    @Override
    public BattleRecord1 mergeFrom(final BattleRecord1 other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRecordId()) {
        setRecordId(other.recordId);
      }
      if (other.hasRecordInfo()) {
        getMutableRecordInfo().mergeFrom(other.recordInfo);
      }
      return this;
    }

    @Override
    public BattleRecord1 clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      recordId = 0;
      recordInfo.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof BattleRecord1)) {
        return false;
      }
      BattleRecord1 other = (BattleRecord1) o;
      return bitField0_ == other.bitField0_
        && (!hasRecordId() || recordId == other.recordId)
        && (!hasRecordInfo() || recordInfo.equals(other.recordInfo));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 72);
        output.writeUInt32NoTag(recordId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 10);
        output.writeMessageNoTag(recordInfo);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(recordId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(recordInfo);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public BattleRecord1 mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 72: {
            // recordId
            recordId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // recordInfo
            input.readMessage(recordInfo);
            bitField0_ |= 0x00000002;
            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_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.recordId, recordId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.recordInfo, recordInfo);
      }
      output.endObject();
    }

    @Override
    public BattleRecord1 mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -799234740:
          case 993548233: {
            if (input.isAtField(FieldNames.recordId)) {
              if (!input.trySkipNullValue()) {
                recordId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 734573727:
          case 1317125084: {
            if (input.isAtField(FieldNames.recordInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(recordInfo);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BattleRecord1Factory implements MessageFactory<BattleRecord1> {
      INSTANCE;

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

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

      static final FieldName recordInfo = FieldName.forField("recordInfo", "record_info");
    }
  }
}
