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

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</code>
     */
    private final RepeatedMessage<FeatureSwitchInfoOuterClass.FeatureSwitchInfo> switchInfoList = RepeatedMessage.newEmptyInstance(FeatureSwitchInfoOuterClass.FeatureSwitchInfo.getFactory());

    private UpdateFeatureSwitchScNotify() {
    }

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

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</code>
     * @return whether the switchInfoList field is set
     */
    public boolean hasSwitchInfoList() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</code>
     * @return this
     */
    public UpdateFeatureSwitchScNotify clearSwitchInfoList() {
      bitField0_ &= ~0x00000001;
      switchInfoList.clear();
      return this;
    }

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</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 #getMutableSwitchInfoList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<FeatureSwitchInfoOuterClass.FeatureSwitchInfo> getSwitchInfoList() {
      return switchInfoList;
    }

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</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<FeatureSwitchInfoOuterClass.FeatureSwitchInfo> getMutableSwitchInfoList(
        ) {
      bitField0_ |= 0x00000001;
      return switchInfoList;
    }

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</code>
     * @param value the switchInfoList to add
     * @return this
     */
    public UpdateFeatureSwitchScNotify addSwitchInfoList(
        final FeatureSwitchInfoOuterClass.FeatureSwitchInfo value) {
      bitField0_ |= 0x00000001;
      switchInfoList.add(value);
      return this;
    }

    /**
     * <code>repeated .FeatureSwitchInfo switch_info_list = 5;</code>
     * @param values the switchInfoList to add
     * @return this
     */
    public UpdateFeatureSwitchScNotify addAllSwitchInfoList(
        final FeatureSwitchInfoOuterClass.FeatureSwitchInfo... values) {
      bitField0_ |= 0x00000001;
      switchInfoList.addAll(values);
      return this;
    }

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

    @Override
    public UpdateFeatureSwitchScNotify mergeFrom(final UpdateFeatureSwitchScNotify other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasSwitchInfoList()) {
        getMutableSwitchInfoList().addAll(other.switchInfoList);
      }
      return this;
    }

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

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

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

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

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

    @Override
    @SuppressWarnings("fallthrough")
    public UpdateFeatureSwitchScNotify mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 42: {
            // switchInfoList
            tag = input.readRepeatedMessage(switchInfoList, tag);
            bitField0_ |= 0x00000001;
            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.writeRepeatedMessage(FieldNames.switchInfoList, switchInfoList);
      }
      output.endObject();
    }

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

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

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

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

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

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

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

    private enum UpdateFeatureSwitchScNotifyFactory implements MessageFactory<UpdateFeatureSwitchScNotify> {
      INSTANCE;

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

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