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

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

    /**
     * <code>optional uint32 server_prefs_id = 8;</code>
     */
    private int serverPrefsId;

    /**
     * <code>optional bytes data = 10;</code>
     */
    private final RepeatedByte data = RepeatedByte.newEmptyInstance();

    private ServerPrefs() {
    }

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

    /**
     * <code>optional uint32 server_prefs_id = 8;</code>
     * @return whether the serverPrefsId field is set
     */
    public boolean hasServerPrefsId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 server_prefs_id = 8;</code>
     * @return this
     */
    public ServerPrefs clearServerPrefsId() {
      bitField0_ &= ~0x00000001;
      serverPrefsId = 0;
      return this;
    }

    /**
     * <code>optional uint32 server_prefs_id = 8;</code>
     * @return the serverPrefsId
     */
    public int getServerPrefsId() {
      return serverPrefsId;
    }

    /**
     * <code>optional uint32 server_prefs_id = 8;</code>
     * @param value the serverPrefsId to set
     * @return this
     */
    public ServerPrefs setServerPrefsId(final int value) {
      bitField0_ |= 0x00000001;
      serverPrefsId = value;
      return this;
    }

    /**
     * <code>optional bytes data = 10;</code>
     * @return whether the data field is set
     */
    public boolean hasData() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional bytes data = 10;</code>
     * @return this
     */
    public ServerPrefs clearData() {
      bitField0_ &= ~0x00000002;
      data.clear();
      return this;
    }

    /**
     * <code>optional bytes data = 10;</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 #getMutableData()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getData() {
      return data;
    }

    /**
     * <code>optional bytes data = 10;</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 RepeatedByte getMutableData() {
      bitField0_ |= 0x00000002;
      return data;
    }

    /**
     * <code>optional bytes data = 10;</code>
     * @param value the data to add
     * @return this
     */
    public ServerPrefs addData(final byte value) {
      bitField0_ |= 0x00000002;
      data.add(value);
      return this;
    }

    /**
     * <code>optional bytes data = 10;</code>
     * @param values the data to add
     * @return this
     */
    public ServerPrefs addAllData(final byte... values) {
      bitField0_ |= 0x00000002;
      data.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes data = 10;</code>
     * @param values the data to set
     * @return this
     */
    public ServerPrefs setData(final byte... values) {
      bitField0_ |= 0x00000002;
      data.copyFrom(values);
      return this;
    }

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

    @Override
    public ServerPrefs mergeFrom(final ServerPrefs other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasServerPrefsId()) {
        setServerPrefsId(other.serverPrefsId);
      }
      if (other.hasData()) {
        getMutableData().copyFrom(other.data);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ServerPrefs)) {
        return false;
      }
      ServerPrefs other = (ServerPrefs) o;
      return bitField0_ == other.bitField0_
        && (!hasServerPrefsId() || serverPrefsId == other.serverPrefsId)
        && (!hasData() || data.equals(other.data));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(serverPrefsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 82);
        output.writeBytesNoTag(data);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(serverPrefsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeBytesSizeNoTag(data);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ServerPrefs mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 64: {
            // serverPrefsId
            serverPrefsId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 82) {
              break;
            }
          }
          case 82: {
            // data
            input.readBytes(data);
            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.writeUInt32(FieldNames.serverPrefsId, serverPrefsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBytes(FieldNames.data, data);
      }
      output.endObject();
    }

    @Override
    public ServerPrefs mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 656672552:
          case 2077691526: {
            if (input.isAtField(FieldNames.serverPrefsId)) {
              if (!input.trySkipNullValue()) {
                serverPrefsId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3076010: {
            if (input.isAtField(FieldNames.data)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(data);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ServerPrefsFactory implements MessageFactory<ServerPrefs> {
      INSTANCE;

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

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

      static final FieldName data = FieldName.forField("data");
    }
  }
}
