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

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

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

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

    private RefreshTriggerByClientScNotify() {
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * <code>repeated uint32 trigger_target_id_list = 3;</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 = 3;</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_ |= 0x00000004;
      return triggerTargetIdList;
    }

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

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

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

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

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof RefreshTriggerByClientScNotify)) {
        return false;
      }
      RefreshTriggerByClientScNotify other = (RefreshTriggerByClientScNotify) o;
      return bitField0_ == other.bitField0_
        && (!hasTriggerEntityId() || triggerEntityId == other.triggerEntityId)
        && (!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) 40);
        output.writeUInt32NoTag(triggerEntityId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(triggerName);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < triggerTargetIdList.length(); i++) {
          output.writeRawByte((byte) 24);
          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.computeStringSizeNoTag(triggerName);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += (1 * triggerTargetIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(triggerTargetIdList);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public RefreshTriggerByClientScNotify mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 40: {
            // triggerEntityId
            triggerEntityId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // triggerName
            input.readString(triggerName);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // triggerTargetIdList [packed=true]
            input.readPackedUInt32(triggerTargetIdList, tag);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 24: {
            // triggerTargetIdList [packed=false]
            tag = input.readRepeatedUInt32(triggerTargetIdList, tag);
            bitField0_ |= 0x00000004;
            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.writeString(FieldNames.triggerName, triggerName);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedUInt32(FieldNames.triggerTargetIdList, triggerTargetIdList);
      }
      output.endObject();
    }

    @Override
    public RefreshTriggerByClientScNotify 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 -681138077:
          case 375632050: {
            if (input.isAtField(FieldNames.triggerName)) {
              if (!input.trySkipNullValue()) {
                input.readString(triggerName);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -482857182:
          case -1827914245: {
            if (input.isAtField(FieldNames.triggerTargetIdList)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(triggerTargetIdList);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum RefreshTriggerByClientScNotifyFactory implements MessageFactory<RefreshTriggerByClientScNotify> {
      INSTANCE;

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

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

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

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