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

    /**
     * <code>optional .RogueMiracleSource source = 7;</code>
     */
    private int source;

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</code>
     */
    private final RogueMiracleOuterClass.RogueMiracle rogueMiracle = RogueMiracleOuterClass.RogueMiracle.newInstance();

    private AddRogueMiracleScNotify() {
    }

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

    /**
     * <code>optional .RogueMiracleSource source = 7;</code>
     * @return whether the source field is set
     */
    public boolean hasSource() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional .RogueMiracleSource source = 7;</code>
     * @return this
     */
    public AddRogueMiracleScNotify clearSource() {
      bitField0_ &= ~0x00000001;
      source = 0;
      return this;
    }

    /**
     * <code>optional .RogueMiracleSource source = 7;</code>
     * @return the source
     */
    public RogueMiracleSourceOuterClass.RogueMiracleSource getSource() {
      return RogueMiracleSourceOuterClass.RogueMiracleSource.forNumber(source);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link AddRogueMiracleScNotify#getSource()}.getNumber().
     *
     * @return numeric wire representation
     */
    public int getSourceValue() {
      return source;
    }

    /**
     * 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 RogueMiracleSourceOuterClass.RogueMiracleSource}. Setting an invalid value
     * can cause {@link AddRogueMiracleScNotify#getSource()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public AddRogueMiracleScNotify setSourceValue(final int value) {
      bitField0_ |= 0x00000001;
      source = value;
      return this;
    }

    /**
     * <code>optional .RogueMiracleSource source = 7;</code>
     * @param value the source to set
     * @return this
     */
    public AddRogueMiracleScNotify setSource(
        final RogueMiracleSourceOuterClass.RogueMiracleSource value) {
      bitField0_ |= 0x00000001;
      source = value.getNumber();
      return this;
    }

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</code>
     * @return whether the rogueMiracle field is set
     */
    public boolean hasRogueMiracle() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</code>
     * @return this
     */
    public AddRogueMiracleScNotify clearRogueMiracle() {
      bitField0_ &= ~0x00000002;
      rogueMiracle.clear();
      return this;
    }

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</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 #getMutableRogueMiracle()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RogueMiracleOuterClass.RogueMiracle getRogueMiracle() {
      return rogueMiracle;
    }

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</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 RogueMiracleOuterClass.RogueMiracle getMutableRogueMiracle() {
      bitField0_ |= 0x00000002;
      return rogueMiracle;
    }

    /**
     * <code>optional .RogueMiracle rogue_miracle = 11;</code>
     * @param value the rogueMiracle to set
     * @return this
     */
    public AddRogueMiracleScNotify setRogueMiracle(
        final RogueMiracleOuterClass.RogueMiracle value) {
      bitField0_ |= 0x00000002;
      rogueMiracle.copyFrom(value);
      return this;
    }

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

    @Override
    public AddRogueMiracleScNotify mergeFrom(final AddRogueMiracleScNotify other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasSource()) {
        setSourceValue(other.source);
      }
      if (other.hasRogueMiracle()) {
        getMutableRogueMiracle().mergeFrom(other.rogueMiracle);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof AddRogueMiracleScNotify)) {
        return false;
      }
      AddRogueMiracleScNotify other = (AddRogueMiracleScNotify) o;
      return bitField0_ == other.bitField0_
        && (!hasSource() || source == other.source)
        && (!hasRogueMiracle() || rogueMiracle.equals(other.rogueMiracle));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 56);
        output.writeEnumNoTag(source);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 90);
        output.writeMessageNoTag(rogueMiracle);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeEnumSizeNoTag(source);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(rogueMiracle);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public AddRogueMiracleScNotify mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 56: {
            // source
            final int value = input.readInt32();
            if (RogueMiracleSourceOuterClass.RogueMiracleSource.forNumber(value) != null) {
              source = value;
              bitField0_ |= 0x00000001;
            }
            tag = input.readTag();
            if (tag != 90) {
              break;
            }
          }
          case 90: {
            // rogueMiracle
            input.readMessage(rogueMiracle);
            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_ & 0x00000001) != 0) {
        output.writeEnum(FieldNames.source, source, RogueMiracleSourceOuterClass.RogueMiracleSource.converter());
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.rogueMiracle, rogueMiracle);
      }
      output.endObject();
    }

    @Override
    public AddRogueMiracleScNotify mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -896505829: {
            if (input.isAtField(FieldNames.source)) {
              if (!input.trySkipNullValue()) {
                final RogueMiracleSourceOuterClass.RogueMiracleSource value = input.readEnum(RogueMiracleSourceOuterClass.RogueMiracleSource.converter());
                if (value != null) {
                  source = value.getNumber();
                  bitField0_ |= 0x00000001;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1479551689:
          case 1697369868: {
            if (input.isAtField(FieldNames.rogueMiracle)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(rogueMiracle);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum AddRogueMiracleScNotifyFactory implements MessageFactory<AddRogueMiracleScNotify> {
      INSTANCE;

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

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

      static final FieldName rogueMiracle = FieldName.forField("rogueMiracle", "rogue_miracle");
    }
  }
}
