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

    /**
     * <code>optional uint32 retcode = 5;</code>
     */
    private int retcode;

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

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</code>
     */
    private final FriendBattleRecordType1OuterClass.FriendBattleRecordType1 withGroup = FriendBattleRecordType1OuterClass.FriendBattleRecordType1.newInstance();

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</code>
     */
    private final FriendBattleRecordType2OuterClass.FriendBattleRecordType2 noGroup = FriendBattleRecordType2OuterClass.FriendBattleRecordType2.newInstance();

    private GetFriendBattleRecordDetailScRsp() {
    }

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

    public boolean hasFriendBattleRecord() {
      return (((bitField0_ & 0x00000003)) != 0);
    }

    public GetFriendBattleRecordDetailScRsp clearFriendBattleRecord() {
      if (hasFriendBattleRecord()) {
        clearWithGroup();
        clearNoGroup();
      }
      return this;
    }

    private void clearFriendBattleRecordOtherWithGroup() {
      if ((((bitField0_ & 0x00000002)) != 0)) {
        clearNoGroup();
      }
    }

    private void clearFriendBattleRecordOtherNoGroup() {
      if ((((bitField0_ & 0x00000001)) != 0)) {
        clearWithGroup();
      }
    }

    /**
     * <code>optional uint32 retcode = 5;</code>
     * @return whether the retcode field is set
     */
    public boolean hasRetcode() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 retcode = 5;</code>
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp clearRetcode() {
      bitField0_ &= ~0x00000004;
      retcode = 0;
      return this;
    }

    /**
     * <code>optional uint32 retcode = 5;</code>
     * @return the retcode
     */
    public int getRetcode() {
      return retcode;
    }

    /**
     * <code>optional uint32 retcode = 5;</code>
     * @param value the retcode to set
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp setRetcode(final int value) {
      bitField0_ |= 0x00000004;
      retcode = value;
      return this;
    }

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

    /**
     * <code>optional uint32 uid = 14;</code>
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp clearUid() {
      bitField0_ &= ~0x00000008;
      uid = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 uid = 14;</code>
     * @param value the uid to set
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp setUid(final int value) {
      bitField0_ |= 0x00000008;
      uid = value;
      return this;
    }

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</code>
     * @return whether the withGroup field is set
     */
    public boolean hasWithGroup() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</code>
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp clearWithGroup() {
      bitField0_ &= ~0x00000001;
      withGroup.clear();
      return this;
    }

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</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 #getMutableWithGroup()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public FriendBattleRecordType1OuterClass.FriendBattleRecordType1 getWithGroup() {
      return withGroup;
    }

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</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 FriendBattleRecordType1OuterClass.FriendBattleRecordType1 getMutableWithGroup() {
      clearFriendBattleRecordOtherWithGroup();
      bitField0_ |= 0x00000001;
      return withGroup;
    }

    /**
     * <code>optional .FriendBattleRecordType1 with_group = 9991;</code>
     * @param value the withGroup to set
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp setWithGroup(
        final FriendBattleRecordType1OuterClass.FriendBattleRecordType1 value) {
      clearFriendBattleRecordOtherWithGroup();
      bitField0_ |= 0x00000001;
      withGroup.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</code>
     * @return whether the noGroup field is set
     */
    public boolean hasNoGroup() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</code>
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp clearNoGroup() {
      bitField0_ &= ~0x00000002;
      noGroup.clear();
      return this;
    }

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</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 #getMutableNoGroup()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public FriendBattleRecordType2OuterClass.FriendBattleRecordType2 getNoGroup() {
      return noGroup;
    }

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</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 FriendBattleRecordType2OuterClass.FriendBattleRecordType2 getMutableNoGroup() {
      clearFriendBattleRecordOtherNoGroup();
      bitField0_ |= 0x00000002;
      return noGroup;
    }

    /**
     * <code>optional .FriendBattleRecordType2 no_group = 9992;</code>
     * @param value the noGroup to set
     * @return this
     */
    public GetFriendBattleRecordDetailScRsp setNoGroup(
        final FriendBattleRecordType2OuterClass.FriendBattleRecordType2 value) {
      clearFriendBattleRecordOtherNoGroup();
      bitField0_ |= 0x00000002;
      noGroup.copyFrom(value);
      return this;
    }

    @Override
    public GetFriendBattleRecordDetailScRsp copyFrom(final GetFriendBattleRecordDetailScRsp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        retcode = other.retcode;
        uid = other.uid;
        withGroup.copyFrom(other.withGroup);
        noGroup.copyFrom(other.noGroup);
      }
      return this;
    }

    @Override
    public GetFriendBattleRecordDetailScRsp mergeFrom(
        final GetFriendBattleRecordDetailScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasUid()) {
        setUid(other.uid);
      }
      if (other.hasWithGroup()) {
        getMutableWithGroup().mergeFrom(other.withGroup);
      }
      if (other.hasNoGroup()) {
        getMutableNoGroup().mergeFrom(other.noGroup);
      }
      return this;
    }

    @Override
    public GetFriendBattleRecordDetailScRsp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      retcode = 0;
      uid = 0;
      withGroup.clear();
      noGroup.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetFriendBattleRecordDetailScRsp)) {
        return false;
      }
      GetFriendBattleRecordDetailScRsp other = (GetFriendBattleRecordDetailScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasUid() || uid == other.uid)
        && (!hasWithGroup() || withGroup.equals(other.withGroup))
        && (!hasNoGroup() || noGroup.equals(other.noGroup));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 112);
        output.writeUInt32NoTag(uid);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 61626);
        output.writeRawByte((byte) 4);
        output.writeMessageNoTag(withGroup);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawLittleEndian16((short) 61634);
        output.writeRawByte((byte) 4);
        output.writeMessageNoTag(noGroup);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(uid);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        size += 3 + ProtoSink.computeMessageSizeNoTag(withGroup);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 3 + ProtoSink.computeMessageSizeNoTag(noGroup);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetFriendBattleRecordDetailScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 40: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 112) {
              break;
            }
          }
          case 112: {
            // uid
            uid = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 79930) {
              break;
            }
          }
          case 79930: {
            // withGroup
            clearFriendBattleRecordOtherWithGroup();
            input.readMessage(withGroup);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 79938) {
              break;
            }
          }
          case 79938: {
            // noGroup
            clearFriendBattleRecordOtherNoGroup();
            input.readMessage(noGroup);
            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_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.retcode, retcode);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.uid, uid);
      }
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeMessage(FieldNames.withGroup, withGroup);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.noGroup, noGroup);
      }
      output.endObject();
    }

    @Override
    public GetFriendBattleRecordDetailScRsp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1097936398: {
            if (input.isAtField(FieldNames.retcode)) {
              if (!input.trySkipNullValue()) {
                retcode = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 115792: {
            if (input.isAtField(FieldNames.uid)) {
              if (!input.trySkipNullValue()) {
                uid = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 890495321:
          case -1782391354: {
            if (input.isAtField(FieldNames.withGroup)) {
              if (!input.trySkipNullValue()) {
                clearFriendBattleRecordOtherWithGroup();
                input.readMessage(withGroup);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2088069438:
          case 982667905: {
            if (input.isAtField(FieldNames.noGroup)) {
              if (!input.trySkipNullValue()) {
                clearFriendBattleRecordOtherNoGroup();
                input.readMessage(noGroup);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetFriendBattleRecordDetailScRspFactory implements MessageFactory<GetFriendBattleRecordDetailScRsp> {
      INSTANCE;

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

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

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

      static final FieldName withGroup = FieldName.forField("withGroup", "with_group");

      static final FieldName noGroup = FieldName.forField("noGroup", "no_group");
    }
  }
}
