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

    /**
     * <code>optional uint32 entry_id = 4;</code>
     */
    private int entryId;

    /**
     * <code>optional uint32 teleport_id = 6;</code>
     */
    private int teleportId;

    private EnterSceneCsReq() {
    }

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

    /**
     * <code>optional uint32 entry_id = 4;</code>
     * @return whether the entryId field is set
     */
    public boolean hasEntryId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 entry_id = 4;</code>
     * @return this
     */
    public EnterSceneCsReq clearEntryId() {
      bitField0_ &= ~0x00000001;
      entryId = 0;
      return this;
    }

    /**
     * <code>optional uint32 entry_id = 4;</code>
     * @return the entryId
     */
    public int getEntryId() {
      return entryId;
    }

    /**
     * <code>optional uint32 entry_id = 4;</code>
     * @param value the entryId to set
     * @return this
     */
    public EnterSceneCsReq setEntryId(final int value) {
      bitField0_ |= 0x00000001;
      entryId = value;
      return this;
    }

    /**
     * <code>optional uint32 teleport_id = 6;</code>
     * @return whether the teleportId field is set
     */
    public boolean hasTeleportId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 teleport_id = 6;</code>
     * @return this
     */
    public EnterSceneCsReq clearTeleportId() {
      bitField0_ &= ~0x00000002;
      teleportId = 0;
      return this;
    }

    /**
     * <code>optional uint32 teleport_id = 6;</code>
     * @return the teleportId
     */
    public int getTeleportId() {
      return teleportId;
    }

    /**
     * <code>optional uint32 teleport_id = 6;</code>
     * @param value the teleportId to set
     * @return this
     */
    public EnterSceneCsReq setTeleportId(final int value) {
      bitField0_ |= 0x00000002;
      teleportId = value;
      return this;
    }

    @Override
    public EnterSceneCsReq copyFrom(final EnterSceneCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        entryId = other.entryId;
        teleportId = other.teleportId;
      }
      return this;
    }

    @Override
    public EnterSceneCsReq mergeFrom(final EnterSceneCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasEntryId()) {
        setEntryId(other.entryId);
      }
      if (other.hasTeleportId()) {
        setTeleportId(other.teleportId);
      }
      return this;
    }

    @Override
    public EnterSceneCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      entryId = 0;
      teleportId = 0;
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof EnterSceneCsReq)) {
        return false;
      }
      EnterSceneCsReq other = (EnterSceneCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasEntryId() || entryId == other.entryId)
        && (!hasTeleportId() || teleportId == other.teleportId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(entryId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(teleportId);
      }
    }

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

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

    @Override
    public EnterSceneCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1591558867:
          case -2093663224: {
            if (input.isAtField(FieldNames.entryId)) {
              if (!input.trySkipNullValue()) {
                entryId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1484004954:
          case 1240508079: {
            if (input.isAtField(FieldNames.teleportId)) {
              if (!input.trySkipNullValue()) {
                teleportId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum EnterSceneCsReqFactory implements MessageFactory<EnterSceneCsReq> {
      INSTANCE;

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

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

      static final FieldName teleportId = FieldName.forField("teleportId", "teleport_id");
    }
  }
}
