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

    /**
     * <code>optional .FeatureSwitchType type = 1;</code>
     */
    private int type;

    /**
     * <code>optional bool is_all_closed = 3;</code>
     */
    private boolean isAllClosed;

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</code>
     */
    private final RepeatedMessage<FeatureSwitchParamOuterClass.FeatureSwitchParam> switchList = RepeatedMessage.newEmptyInstance(FeatureSwitchParamOuterClass.FeatureSwitchParam.getFactory());

    private FeatureSwitchInfo() {
    }

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

    /**
     * <code>optional .FeatureSwitchType type = 1;</code>
     * @return whether the type field is set
     */
    public boolean hasType() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .FeatureSwitchType type = 1;</code>
     * @return this
     */
    public FeatureSwitchInfo clearType() {
      bitField0_ &= ~0x00000001;
      type = 0;
      return this;
    }

    /**
     * <code>optional .FeatureSwitchType type = 1;</code>
     * @return the type
     */
    public FeatureSwitchTypeOuterClass.FeatureSwitchType getType() {
      return FeatureSwitchTypeOuterClass.FeatureSwitchType.forNumber(type);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link FeatureSwitchInfo#getType()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getTypeValue() {
      return type;
    }

    /**
     * Sets the value of the internal enum store. This does not
     * do any validity checks, so be sure to use appropriate value
     * constants from {@link FeatureSwitchTypeOuterClass.FeatureSwitchType}. Setting an invalid value
     * can cause {@link FeatureSwitchInfo#getType()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public FeatureSwitchInfo setTypeValue(final int value) {
      bitField0_ |= 0x00000001;
      type = value;
      return this;
    }

    /**
     * <code>optional .FeatureSwitchType type = 1;</code>
     * @param value the type to set
     * @return this
     */
    public FeatureSwitchInfo setType(final FeatureSwitchTypeOuterClass.FeatureSwitchType value) {
      bitField0_ |= 0x00000001;
      type = value.getNumber();
      return this;
    }

    /**
     * <code>optional bool is_all_closed = 3;</code>
     * @return whether the isAllClosed field is set
     */
    public boolean hasIsAllClosed() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional bool is_all_closed = 3;</code>
     * @return this
     */
    public FeatureSwitchInfo clearIsAllClosed() {
      bitField0_ &= ~0x00000002;
      isAllClosed = false;
      return this;
    }

    /**
     * <code>optional bool is_all_closed = 3;</code>
     * @return the isAllClosed
     */
    public boolean getIsAllClosed() {
      return isAllClosed;
    }

    /**
     * <code>optional bool is_all_closed = 3;</code>
     * @param value the isAllClosed to set
     * @return this
     */
    public FeatureSwitchInfo setIsAllClosed(final boolean value) {
      bitField0_ |= 0x00000002;
      isAllClosed = value;
      return this;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</code>
     * @return whether the switchList field is set
     */
    public boolean hasSwitchList() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</code>
     * @return this
     */
    public FeatureSwitchInfo clearSwitchList() {
      bitField0_ &= ~0x00000004;
      switchList.clear();
      return this;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</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 #getMutableSwitchList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<FeatureSwitchParamOuterClass.FeatureSwitchParam> getSwitchList() {
      return switchList;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</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<FeatureSwitchParamOuterClass.FeatureSwitchParam> getMutableSwitchList() {
      bitField0_ |= 0x00000004;
      return switchList;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</code>
     * @param value the switchList to add
     * @return this
     */
    public FeatureSwitchInfo addSwitchList(
        final FeatureSwitchParamOuterClass.FeatureSwitchParam value) {
      bitField0_ |= 0x00000004;
      switchList.add(value);
      return this;
    }

    /**
     * <code>repeated .FeatureSwitchParam switch_list = 2;</code>
     * @param values the switchList to add
     * @return this
     */
    public FeatureSwitchInfo addAllSwitchList(
        final FeatureSwitchParamOuterClass.FeatureSwitchParam... values) {
      bitField0_ |= 0x00000004;
      switchList.addAll(values);
      return this;
    }

    @Override
    public FeatureSwitchInfo copyFrom(final FeatureSwitchInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        type = other.type;
        isAllClosed = other.isAllClosed;
        switchList.copyFrom(other.switchList);
      }
      return this;
    }

    @Override
    public FeatureSwitchInfo mergeFrom(final FeatureSwitchInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasType()) {
        setTypeValue(other.type);
      }
      if (other.hasIsAllClosed()) {
        setIsAllClosed(other.isAllClosed);
      }
      if (other.hasSwitchList()) {
        getMutableSwitchList().addAll(other.switchList);
      }
      return this;
    }

    @Override
    public FeatureSwitchInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      type = 0;
      isAllClosed = false;
      switchList.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof FeatureSwitchInfo)) {
        return false;
      }
      FeatureSwitchInfo other = (FeatureSwitchInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasType() || type == other.type)
        && (!hasIsAllClosed() || isAllClosed == other.isAllClosed)
        && (!hasSwitchList() || switchList.equals(other.switchList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeEnumNoTag(type);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 24);
        output.writeBoolNoTag(isAllClosed);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < switchList.length(); i++) {
          output.writeRawByte((byte) 18);
          output.writeMessageNoTag(switchList.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(type);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * switchList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(switchList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public FeatureSwitchInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // type
            final int value = input.readInt32();
            if (FeatureSwitchTypeOuterClass.FeatureSwitchType.forNumber(value) != null) {
              type = value;
              bitField0_ |= 0x00000001;
            }
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // isAllClosed
            isAllClosed = input.readBool();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // switchList
            tag = input.readRepeatedMessage(switchList, tag);
            bitField0_ |= 0x00000004;
            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.writeEnum(FieldNames.type, type, FeatureSwitchTypeOuterClass.FeatureSwitchType.converter());
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBool(FieldNames.isAllClosed, isAllClosed);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.switchList, switchList);
      }
      output.endObject();
    }

    @Override
    public FeatureSwitchInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 3575610: {
            if (input.isAtField(FieldNames.type)) {
              if (!input.trySkipNullValue()) {
                final FeatureSwitchTypeOuterClass.FeatureSwitchType value = input.readEnum(FeatureSwitchTypeOuterClass.FeatureSwitchType.converter());
                if (value != null) {
                  type = value.getNumber();
                  bitField0_ |= 0x00000001;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 281414755:
          case -912209921: {
            if (input.isAtField(FieldNames.isAllClosed)) {
              if (!input.trySkipNullValue()) {
                isAllClosed = input.readBool();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -347528718:
          case 2129138377: {
            if (input.isAtField(FieldNames.switchList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(switchList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum FeatureSwitchInfoFactory implements MessageFactory<FeatureSwitchInfo> {
      INSTANCE;

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

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

      static final FieldName isAllClosed = FieldName.forField("isAllClosed", "is_all_closed");

      static final FieldName switchList = FieldName.forField("switchList", "switch_list");
    }
  }
}
