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

    /**
     * <code>optional .RogueBuffSource source = 4;</code>
     */
    private int source;

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</code>
     */
    private final RogueBuffOuterClass.RogueBuff mazeBuffInfo = RogueBuffOuterClass.RogueBuff.newInstance();

    private AddRogueBuffScNotify() {
    }

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

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

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

    /**
     * <code>optional .RogueBuffSource source = 4;</code>
     * @return the source
     */
    public RogueBuffSourceOuterClass.RogueBuffSource getSource() {
      return RogueBuffSourceOuterClass.RogueBuffSource.forNumber(source);
    }

    /**
     * Gets the value of the internal enum store. The result is
     * equivalent to {@link AddRogueBuffScNotify#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 RogueBuffSourceOuterClass.RogueBuffSource}. Setting an invalid value
     * can cause {@link AddRogueBuffScNotify#getSource()} to return null
     *
     * @param value the numeric wire value to set
     * @return this
     */
    public AddRogueBuffScNotify setSourceValue(final int value) {
      bitField0_ |= 0x00000001;
      source = value;
      return this;
    }

    /**
     * <code>optional .RogueBuffSource source = 4;</code>
     * @param value the source to set
     * @return this
     */
    public AddRogueBuffScNotify setSource(final RogueBuffSourceOuterClass.RogueBuffSource value) {
      bitField0_ |= 0x00000001;
      source = value.getNumber();
      return this;
    }

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</code>
     * @return whether the mazeBuffInfo field is set
     */
    public boolean hasMazeBuffInfo() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</code>
     * @return this
     */
    public AddRogueBuffScNotify clearMazeBuffInfo() {
      bitField0_ &= ~0x00000002;
      mazeBuffInfo.clear();
      return this;
    }

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</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 #getMutableMazeBuffInfo()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RogueBuffOuterClass.RogueBuff getMazeBuffInfo() {
      return mazeBuffInfo;
    }

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</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 RogueBuffOuterClass.RogueBuff getMutableMazeBuffInfo() {
      bitField0_ |= 0x00000002;
      return mazeBuffInfo;
    }

    /**
     * <code>optional .RogueBuff maze_buff_info = 1;</code>
     * @param value the mazeBuffInfo to set
     * @return this
     */
    public AddRogueBuffScNotify setMazeBuffInfo(final RogueBuffOuterClass.RogueBuff value) {
      bitField0_ |= 0x00000002;
      mazeBuffInfo.copyFrom(value);
      return this;
    }

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

    @Override
    public AddRogueBuffScNotify mergeFrom(final AddRogueBuffScNotify other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasSource()) {
        setSourceValue(other.source);
      }
      if (other.hasMazeBuffInfo()) {
        getMutableMazeBuffInfo().mergeFrom(other.mazeBuffInfo);
      }
      return this;
    }

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

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

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

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

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

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

    @Override
    public AddRogueBuffScNotify 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 RogueBuffSourceOuterClass.RogueBuffSource value = input.readEnum(RogueBuffSourceOuterClass.RogueBuffSource.converter());
                if (value != null) {
                  source = value.getNumber();
                  bitField0_ |= 0x00000001;
                } else {
                  input.skipUnknownEnumValue();
                }
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1147143296:
          case -1635080038: {
            if (input.isAtField(FieldNames.mazeBuffInfo)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(mazeBuffInfo);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum AddRogueBuffScNotifyFactory implements MessageFactory<AddRogueBuffScNotify> {
      INSTANCE;

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

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

      static final FieldName mazeBuffInfo = FieldName.forField("mazeBuffInfo", "maze_buff_info");
    }
  }
}
