// 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.RepeatedInt;

public final class StageMergedInfoOuterClass {
  /**
   * Protobuf type {@code StageMergedInfo}
   */
  public static final class StageMergedInfo extends ProtoMessage<StageMergedInfo> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional uint32 stage_merged_id = 11;</code>
     */
    private int stageMergedId;

    /**
     * <code>optional bool bool7 = 2;</code>
     */
    private boolean bool7;

    /**
     * <code>optional bool bool10 = 6;</code>
     */
    private boolean bool10;

    /**
     * <code>repeated uint32 stage_periods = 15;</code>
     */
    private final RepeatedInt stagePeriods = RepeatedInt.newEmptyInstance();

    private StageMergedInfo() {
    }

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

    /**
     * <code>optional uint32 stage_merged_id = 11;</code>
     * @return whether the stageMergedId field is set
     */
    public boolean hasStageMergedId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 stage_merged_id = 11;</code>
     * @return this
     */
    public StageMergedInfo clearStageMergedId() {
      bitField0_ &= ~0x00000001;
      stageMergedId = 0;
      return this;
    }

    /**
     * <code>optional uint32 stage_merged_id = 11;</code>
     * @return the stageMergedId
     */
    public int getStageMergedId() {
      return stageMergedId;
    }

    /**
     * <code>optional uint32 stage_merged_id = 11;</code>
     * @param value the stageMergedId to set
     * @return this
     */
    public StageMergedInfo setStageMergedId(final int value) {
      bitField0_ |= 0x00000001;
      stageMergedId = value;
      return this;
    }

    /**
     * <code>optional bool bool7 = 2;</code>
     * @return whether the bool7 field is set
     */
    public boolean hasBool7() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional bool bool7 = 2;</code>
     * @return this
     */
    public StageMergedInfo clearBool7() {
      bitField0_ &= ~0x00000002;
      bool7 = false;
      return this;
    }

    /**
     * <code>optional bool bool7 = 2;</code>
     * @return the bool7
     */
    public boolean getBool7() {
      return bool7;
    }

    /**
     * <code>optional bool bool7 = 2;</code>
     * @param value the bool7 to set
     * @return this
     */
    public StageMergedInfo setBool7(final boolean value) {
      bitField0_ |= 0x00000002;
      bool7 = value;
      return this;
    }

    /**
     * <code>optional bool bool10 = 6;</code>
     * @return whether the bool10 field is set
     */
    public boolean hasBool10() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional bool bool10 = 6;</code>
     * @return this
     */
    public StageMergedInfo clearBool10() {
      bitField0_ &= ~0x00000004;
      bool10 = false;
      return this;
    }

    /**
     * <code>optional bool bool10 = 6;</code>
     * @return the bool10
     */
    public boolean getBool10() {
      return bool10;
    }

    /**
     * <code>optional bool bool10 = 6;</code>
     * @param value the bool10 to set
     * @return this
     */
    public StageMergedInfo setBool10(final boolean value) {
      bitField0_ |= 0x00000004;
      bool10 = value;
      return this;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</code>
     * @return whether the stagePeriods field is set
     */
    public boolean hasStagePeriods() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</code>
     * @return this
     */
    public StageMergedInfo clearStagePeriods() {
      bitField0_ &= ~0x00000008;
      stagePeriods.clear();
      return this;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</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 #getMutableStagePeriods()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getStagePeriods() {
      return stagePeriods;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</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 RepeatedInt getMutableStagePeriods() {
      bitField0_ |= 0x00000008;
      return stagePeriods;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</code>
     * @param value the stagePeriods to add
     * @return this
     */
    public StageMergedInfo addStagePeriods(final int value) {
      bitField0_ |= 0x00000008;
      stagePeriods.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 stage_periods = 15;</code>
     * @param values the stagePeriods to add
     * @return this
     */
    public StageMergedInfo addAllStagePeriods(final int... values) {
      bitField0_ |= 0x00000008;
      stagePeriods.addAll(values);
      return this;
    }

    @Override
    public StageMergedInfo copyFrom(final StageMergedInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        stageMergedId = other.stageMergedId;
        bool7 = other.bool7;
        bool10 = other.bool10;
        stagePeriods.copyFrom(other.stagePeriods);
      }
      return this;
    }

    @Override
    public StageMergedInfo mergeFrom(final StageMergedInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasStageMergedId()) {
        setStageMergedId(other.stageMergedId);
      }
      if (other.hasBool7()) {
        setBool7(other.bool7);
      }
      if (other.hasBool10()) {
        setBool10(other.bool10);
      }
      if (other.hasStagePeriods()) {
        getMutableStagePeriods().addAll(other.stagePeriods);
      }
      return this;
    }

    @Override
    public StageMergedInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      stageMergedId = 0;
      bool7 = false;
      bool10 = false;
      stagePeriods.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof StageMergedInfo)) {
        return false;
      }
      StageMergedInfo other = (StageMergedInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasStageMergedId() || stageMergedId == other.stageMergedId)
        && (!hasBool7() || bool7 == other.bool7)
        && (!hasBool10() || bool10 == other.bool10)
        && (!hasStagePeriods() || stagePeriods.equals(other.stagePeriods));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 88);
        output.writeUInt32NoTag(stageMergedId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeBoolNoTag(bool7);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 48);
        output.writeBoolNoTag(bool10);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < stagePeriods.length(); i++) {
          output.writeRawByte((byte) 120);
          output.writeUInt32NoTag(stagePeriods.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(stageMergedId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * stagePeriods.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(stagePeriods);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public StageMergedInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 88: {
            // stageMergedId
            stageMergedId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // bool7
            bool7 = input.readBool();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // bool10
            bool10 = input.readBool();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 122) {
              break;
            }
          }
          case 122: {
            // stagePeriods [packed=true]
            input.readPackedUInt32(stagePeriods, tag);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 120: {
            // stagePeriods [packed=false]
            tag = input.readRepeatedUInt32(stagePeriods, tag);
            bitField0_ |= 0x00000008;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.stageMergedId, stageMergedId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBool(FieldNames.bool7, bool7);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeBool(FieldNames.bool10, bool10);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedUInt32(FieldNames.stagePeriods, stagePeriods);
      }
      output.endObject();
    }

    @Override
    public StageMergedInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1165878651:
          case -190036211: {
            if (input.isAtField(FieldNames.stageMergedId)) {
              if (!input.trySkipNullValue()) {
                stageMergedId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 93921933: {
            if (input.isAtField(FieldNames.bool7)) {
              if (!input.trySkipNullValue()) {
                bool7 = input.readBool();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1383387511: {
            if (input.isAtField(FieldNames.bool10)) {
              if (!input.trySkipNullValue()) {
                bool10 = input.readBool();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1516592628:
          case 950652561: {
            if (input.isAtField(FieldNames.stagePeriods)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(stagePeriods);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum StageMergedInfoFactory implements MessageFactory<StageMergedInfo> {
      INSTANCE;

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

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

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

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

      static final FieldName stagePeriods = FieldName.forField("stagePeriods", "stage_periods");
    }
  }
}
