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

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

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</code>
     */
    private final RepeatedMessage<SocialEventServerCacheOuterClass.SocialEventServerCache> socialEvent = RepeatedMessage.newEmptyInstance(SocialEventServerCacheOuterClass.SocialEventServerCache.getFactory());

    private GetSocialEventServerCacheScRsp() {
    }

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

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

    /**
     * <code>optional uint32 retcode = 12;</code>
     * @return this
     */
    public GetSocialEventServerCacheScRsp clearRetcode() {
      bitField0_ &= ~0x00000001;
      retcode = 0;
      return this;
    }

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

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

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</code>
     * @return whether the socialEvent field is set
     */
    public boolean hasSocialEvent() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</code>
     * @return this
     */
    public GetSocialEventServerCacheScRsp clearSocialEvent() {
      bitField0_ &= ~0x00000002;
      socialEvent.clear();
      return this;
    }

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</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 #getMutableSocialEvent()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<SocialEventServerCacheOuterClass.SocialEventServerCache> getSocialEvent(
        ) {
      return socialEvent;
    }

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</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<SocialEventServerCacheOuterClass.SocialEventServerCache> getMutableSocialEvent(
        ) {
      bitField0_ |= 0x00000002;
      return socialEvent;
    }

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</code>
     * @param value the socialEvent to add
     * @return this
     */
    public GetSocialEventServerCacheScRsp addSocialEvent(
        final SocialEventServerCacheOuterClass.SocialEventServerCache value) {
      bitField0_ |= 0x00000002;
      socialEvent.add(value);
      return this;
    }

    /**
     * <code>repeated .SocialEventServerCache social_event = 6;</code>
     * @param values the socialEvent to add
     * @return this
     */
    public GetSocialEventServerCacheScRsp addAllSocialEvent(
        final SocialEventServerCacheOuterClass.SocialEventServerCache... values) {
      bitField0_ |= 0x00000002;
      socialEvent.addAll(values);
      return this;
    }

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

    @Override
    public GetSocialEventServerCacheScRsp mergeFrom(final GetSocialEventServerCacheScRsp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRetcode()) {
        setRetcode(other.retcode);
      }
      if (other.hasSocialEvent()) {
        getMutableSocialEvent().addAll(other.socialEvent);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof GetSocialEventServerCacheScRsp)) {
        return false;
      }
      GetSocialEventServerCacheScRsp other = (GetSocialEventServerCacheScRsp) o;
      return bitField0_ == other.bitField0_
        && (!hasRetcode() || retcode == other.retcode)
        && (!hasSocialEvent() || socialEvent.equals(other.socialEvent));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < socialEvent.length(); i++) {
          output.writeRawByte((byte) 50);
          output.writeMessageNoTag(socialEvent.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += (1 * socialEvent.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(socialEvent);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public GetSocialEventServerCacheScRsp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 96: {
            // retcode
            retcode = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 50) {
              break;
            }
          }
          case 50: {
            // socialEvent
            tag = input.readRepeatedMessage(socialEvent, tag);
            bitField0_ |= 0x00000002;
            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.retcode, retcode);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRepeatedMessage(FieldNames.socialEvent, socialEvent);
      }
      output.endObject();
    }

    @Override
    public GetSocialEventServerCacheScRsp 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_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2014181587:
          case -1580931256: {
            if (input.isAtField(FieldNames.socialEvent)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(socialEvent);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum GetSocialEventServerCacheScRspFactory implements MessageFactory<GetSocialEventServerCacheScRsp> {
      INSTANCE;

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

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

      static final FieldName socialEvent = FieldName.forField("socialEvent", "social_event");
    }
  }
}
