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

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</code>
     */
    private final BattleRecordType2OuterClass.BattleRecordType2 recordType2 = BattleRecordType2OuterClass.BattleRecordType2.newInstance();

    private FriendBattleRecordType2() {
    }

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

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

    public FriendBattleRecordType2 clearRecord() {
      if (hasRecord()) {
        clearRecordType2();
      }
      return this;
    }

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</code>
     * @return whether the recordType2 field is set
     */
    public boolean hasRecordType2() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</code>
     * @return this
     */
    public FriendBattleRecordType2 clearRecordType2() {
      bitField0_ &= ~0x00000001;
      recordType2.clear();
      return this;
    }

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</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 #getMutableRecordType2()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public BattleRecordType2OuterClass.BattleRecordType2 getRecordType2() {
      return recordType2;
    }

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</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 BattleRecordType2OuterClass.BattleRecordType2 getMutableRecordType2() {
      bitField0_ |= 0x00000001;
      return recordType2;
    }

    /**
     * <code>optional .BattleRecordType2 record_type2 = 1722;</code>
     * @param value the recordType2 to set
     * @return this
     */
    public FriendBattleRecordType2 setRecordType2(
        final BattleRecordType2OuterClass.BattleRecordType2 value) {
      bitField0_ |= 0x00000001;
      recordType2.copyFrom(value);
      return this;
    }

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

    @Override
    public FriendBattleRecordType2 mergeFrom(final FriendBattleRecordType2 other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRecordType2()) {
        getMutableRecordType2().mergeFrom(other.recordType2);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FriendBattleRecordType2)) {
        return false;
      }
      FriendBattleRecordType2 other = (FriendBattleRecordType2) o;
      return bitField0_ == other.bitField0_
        && (!hasRecordType2() || recordType2.equals(other.recordType2));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 27602);
        output.writeMessageNoTag(recordType2);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeMessageSizeNoTag(recordType2);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FriendBattleRecordType2 mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 13778: {
            // recordType2
            input.readMessage(recordType2);
            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_ & 0x00000001) != 0) {
        output.writeMessage(FieldNames.recordType2, recordType2);
      }
      output.endObject();
    }

    @Override
    public FriendBattleRecordType2 mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1307444839:
          case -2108299574: {
            if (input.isAtField(FieldNames.recordType2)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(recordType2);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FriendBattleRecordType2Factory implements MessageFactory<FriendBattleRecordType2> {
      INSTANCE;

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

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