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

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

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

    /**
     * <code>repeated .EntityMotion entity_motion_list = 10;</code>
     */
    private final RepeatedMessage<EntityMotionOuterClass.EntityMotion> entityMotionList = RepeatedMessage.newEmptyInstance(EntityMotionOuterClass.EntityMotion.getFactory());

    private SceneEntityMoveCsReq() {
    }

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

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

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

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

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

    /**
     * <code>repeated .EntityMotion entity_motion_list = 10;</code>
     * @return whether the entityMotionList field is set
     */
    public boolean hasEntityMotionList() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated .EntityMotion entity_motion_list = 10;</code>
     * @return this
     */
    public SceneEntityMoveCsReq clearEntityMotionList() {
      bitField0_ &= ~0x00000002;
      entityMotionList.clear();
      return this;
    }

    /**
     * <code>repeated .EntityMotion entity_motion_list = 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 #getMutableEntityMotionList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<EntityMotionOuterClass.EntityMotion> getEntityMotionList() {
      return entityMotionList;
    }

    /**
     * <code>repeated .EntityMotion entity_motion_list = 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 RepeatedMessage<EntityMotionOuterClass.EntityMotion> getMutableEntityMotionList() {
      bitField0_ |= 0x00000002;
      return entityMotionList;
    }

    /**
     * <code>repeated .EntityMotion entity_motion_list = 10;</code>
     * @param value the entityMotionList to add
     * @return this
     */
    public SceneEntityMoveCsReq addEntityMotionList(
        final EntityMotionOuterClass.EntityMotion value) {
      bitField0_ |= 0x00000002;
      entityMotionList.add(value);
      return this;
    }

    /**
     * <code>repeated .EntityMotion entity_motion_list = 10;</code>
     * @param values the entityMotionList to add
     * @return this
     */
    public SceneEntityMoveCsReq addAllEntityMotionList(
        final EntityMotionOuterClass.EntityMotion... values) {
      bitField0_ |= 0x00000002;
      entityMotionList.addAll(values);
      return this;
    }

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

    @Override
    public SceneEntityMoveCsReq mergeFrom(final SceneEntityMoveCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasEntryId()) {
        setEntryId(other.entryId);
      }
      if (other.hasEntityMotionList()) {
        getMutableEntityMotionList().addAll(other.entityMotionList);
      }
      return this;
    }

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

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

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

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(entryId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < entityMotionList.length(); i++) {
          output.writeRawByte((byte) 82);
          output.writeMessageNoTag(entityMotionList.get(i));
        }
      }
    }

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

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

    @Override
    public SceneEntityMoveCsReq 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 -276915785:
          case 59281707: {
            if (input.isAtField(FieldNames.entityMotionList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(entityMotionList);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SceneEntityMoveCsReqFactory implements MessageFactory<SceneEntityMoveCsReq> {
      INSTANCE;

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

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

      static final FieldName entityMotionList = FieldName.forField("entityMotionList", "entity_motion_list");
    }
  }
}
