// 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.RepeatedInt;
import us.hebi.quickbuf.Utf8String;

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

    /**
     * <code>optional uint32 trigger_entity_id = 7;</code>
     */
    private int triggerEntityId;

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</code>
     */
    private final MotionInfoOuterClass.MotionInfo triggerMotion = MotionInfoOuterClass.MotionInfo.newInstance();

    /**
     * <code>optional string trigger_name = 5;</code>
     */
    private final Utf8String triggerName = Utf8String.newEmptyInstance();

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</code>
     */
    private final RepeatedInt triggerTargetIdList = RepeatedInt.newEmptyInstance();

    private RefreshTriggerByClientCsReq() {
    }

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

    /**
     * <code>optional uint32 trigger_entity_id = 7;</code>
     * @return whether the triggerEntityId field is set
     */
    public boolean hasTriggerEntityId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 trigger_entity_id = 7;</code>
     * @return this
     */
    public RefreshTriggerByClientCsReq clearTriggerEntityId() {
      bitField0_ &= ~0x00000001;
      triggerEntityId = 0;
      return this;
    }

    /**
     * <code>optional uint32 trigger_entity_id = 7;</code>
     * @return the triggerEntityId
     */
    public int getTriggerEntityId() {
      return triggerEntityId;
    }

    /**
     * <code>optional uint32 trigger_entity_id = 7;</code>
     * @param value the triggerEntityId to set
     * @return this
     */
    public RefreshTriggerByClientCsReq setTriggerEntityId(final int value) {
      bitField0_ |= 0x00000001;
      triggerEntityId = value;
      return this;
    }

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</code>
     * @return whether the triggerMotion field is set
     */
    public boolean hasTriggerMotion() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</code>
     * @return this
     */
    public RefreshTriggerByClientCsReq clearTriggerMotion() {
      bitField0_ &= ~0x00000002;
      triggerMotion.clear();
      return this;
    }

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</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 #getMutableTriggerMotion()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public MotionInfoOuterClass.MotionInfo getTriggerMotion() {
      return triggerMotion;
    }

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</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 MotionInfoOuterClass.MotionInfo getMutableTriggerMotion() {
      bitField0_ |= 0x00000002;
      return triggerMotion;
    }

    /**
     * <code>optional .MotionInfo trigger_motion = 13;</code>
     * @param value the triggerMotion to set
     * @return this
     */
    public RefreshTriggerByClientCsReq setTriggerMotion(
        final MotionInfoOuterClass.MotionInfo value) {
      bitField0_ |= 0x00000002;
      triggerMotion.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @return whether the triggerName field is set
     */
    public boolean hasTriggerName() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @return this
     */
    public RefreshTriggerByClientCsReq clearTriggerName() {
      bitField0_ &= ~0x00000004;
      triggerName.clear();
      return this;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @return the triggerName
     */
    public String getTriggerName() {
      return triggerName.getString();
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @return internal {@code Utf8String} representation of triggerName for reading
     */
    public Utf8String getTriggerNameBytes() {
      return this.triggerName;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @return internal {@code Utf8String} representation of triggerName for modifications
     */
    public Utf8String getMutableTriggerNameBytes() {
      bitField0_ |= 0x00000004;
      return this.triggerName;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @param value the triggerName to set
     * @return this
     */
    public RefreshTriggerByClientCsReq setTriggerName(final CharSequence value) {
      bitField0_ |= 0x00000004;
      triggerName.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string trigger_name = 5;</code>
     * @param value the triggerName to set
     * @return this
     */
    public RefreshTriggerByClientCsReq setTriggerName(final Utf8String value) {
      bitField0_ |= 0x00000004;
      triggerName.copyFrom(value);
      return this;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</code>
     * @return whether the triggerTargetIdList field is set
     */
    public boolean hasTriggerTargetIdList() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</code>
     * @return this
     */
    public RefreshTriggerByClientCsReq clearTriggerTargetIdList() {
      bitField0_ &= ~0x00000008;
      triggerTargetIdList.clear();
      return this;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</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 #getMutableTriggerTargetIdList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getTriggerTargetIdList() {
      return triggerTargetIdList;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</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 RepeatedInt getMutableTriggerTargetIdList() {
      bitField0_ |= 0x00000008;
      return triggerTargetIdList;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</code>
     * @param value the triggerTargetIdList to add
     * @return this
     */
    public RefreshTriggerByClientCsReq addTriggerTargetIdList(final int value) {
      bitField0_ |= 0x00000008;
      triggerTargetIdList.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 trigger_target_id_list = 2;</code>
     * @param values the triggerTargetIdList to add
     * @return this
     */
    public RefreshTriggerByClientCsReq addAllTriggerTargetIdList(final int... values) {
      bitField0_ |= 0x00000008;
      triggerTargetIdList.addAll(values);
      return this;
    }

    @Override
    public RefreshTriggerByClientCsReq copyFrom(final RefreshTriggerByClientCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        triggerEntityId = other.triggerEntityId;
        triggerMotion.copyFrom(other.triggerMotion);
        triggerName.copyFrom(other.triggerName);
        triggerTargetIdList.copyFrom(other.triggerTargetIdList);
      }
      return this;
    }

    @Override
    public RefreshTriggerByClientCsReq mergeFrom(final RefreshTriggerByClientCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasTriggerEntityId()) {
        setTriggerEntityId(other.triggerEntityId);
      }
      if (other.hasTriggerMotion()) {
        getMutableTriggerMotion().mergeFrom(other.triggerMotion);
      }
      if (other.hasTriggerName()) {
        getMutableTriggerNameBytes().copyFrom(other.triggerName);
      }
      if (other.hasTriggerTargetIdList()) {
        getMutableTriggerTargetIdList().addAll(other.triggerTargetIdList);
      }
      return this;
    }

    @Override
    public RefreshTriggerByClientCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      triggerEntityId = 0;
      triggerMotion.clear();
      triggerName.clear();
      triggerTargetIdList.clear();
      return this;
    }

    @Override
    public RefreshTriggerByClientCsReq clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      triggerMotion.clearQuick();
      triggerName.clear();
      triggerTargetIdList.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof RefreshTriggerByClientCsReq)) {
        return false;
      }
      RefreshTriggerByClientCsReq other = (RefreshTriggerByClientCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasTriggerEntityId() || triggerEntityId == other.triggerEntityId)
        && (!hasTriggerMotion() || triggerMotion.equals(other.triggerMotion))
        && (!hasTriggerName() || triggerName.equals(other.triggerName))
        && (!hasTriggerTargetIdList() || triggerTargetIdList.equals(other.triggerTargetIdList));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 56);
        output.writeUInt32NoTag(triggerEntityId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 106);
        output.writeMessageNoTag(triggerMotion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 42);
        output.writeStringNoTag(triggerName);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < triggerTargetIdList.length(); i++) {
          output.writeRawByte((byte) 16);
          output.writeUInt32NoTag(triggerTargetIdList.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(triggerEntityId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(triggerMotion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeStringSizeNoTag(triggerName);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += (1 * triggerTargetIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(triggerTargetIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public RefreshTriggerByClientCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 56: {
            // triggerEntityId
            triggerEntityId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 106) {
              break;
            }
          }
          case 106: {
            // triggerMotion
            input.readMessage(triggerMotion);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 42) {
              break;
            }
          }
          case 42: {
            // triggerName
            input.readString(triggerName);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // triggerTargetIdList [packed=true]
            input.readPackedUInt32(triggerTargetIdList, tag);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 16: {
            // triggerTargetIdList [packed=false]
            tag = input.readRepeatedUInt32(triggerTargetIdList, tag);
            bitField0_ |= 0x00000008;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.triggerEntityId, triggerEntityId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeMessage(FieldNames.triggerMotion, triggerMotion);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeString(FieldNames.triggerName, triggerName);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedUInt32(FieldNames.triggerTargetIdList, triggerTargetIdList);
      }
      output.endObject();
    }

    @Override
    public RefreshTriggerByClientCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 242025014:
          case -2081789648: {
            if (input.isAtField(FieldNames.triggerEntityId)) {
              if (!input.trySkipNullValue()) {
                triggerEntityId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1754146930:
          case 189663261: {
            if (input.isAtField(FieldNames.triggerMotion)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(triggerMotion);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -681138077:
          case 375632050: {
            if (input.isAtField(FieldNames.triggerName)) {
              if (!input.trySkipNullValue()) {
                input.readString(triggerName);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -482857182:
          case -1827914245: {
            if (input.isAtField(FieldNames.triggerTargetIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(triggerTargetIdList);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum RefreshTriggerByClientCsReqFactory implements MessageFactory<RefreshTriggerByClientCsReq> {
      INSTANCE;

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

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

      static final FieldName triggerMotion = FieldName.forField("triggerMotion", "trigger_motion");

      static final FieldName triggerName = FieldName.forField("triggerName", "trigger_name");

      static final FieldName triggerTargetIdList = FieldName.forField("triggerTargetIdList", "trigger_target_id_list");
    }
  }
}
