// 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 TextJoinInfoOuterClass {
  /**
   * <pre>
   *  TODO: CHECK
   * </pre>
   *
   * Protobuf type {@code TextJoinInfo}
   */
  public static final class TextJoinInfo extends ProtoMessage<TextJoinInfo> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional uint32 text_item_id = 12;</code>
     */
    private int textItemId;

    /**
     * <code>optional uint32 text_item_config_id = 15;</code>
     */
    private int textItemConfigId;

    private TextJoinInfo() {
    }

    /**
     * <pre>
     *  TODO: CHECK
     * </pre>
     *
     * @return a new empty instance of {@code TextJoinInfo}
     */
    public static TextJoinInfo newInstance() {
      return new TextJoinInfo();
    }

    /**
     * <code>optional uint32 text_item_id = 12;</code>
     * @return whether the textItemId field is set
     */
    public boolean hasTextItemId() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 text_item_id = 12;</code>
     * @return this
     */
    public TextJoinInfo clearTextItemId() {
      bitField0_ &= ~0x00000001;
      textItemId = 0;
      return this;
    }

    /**
     * <code>optional uint32 text_item_id = 12;</code>
     * @return the textItemId
     */
    public int getTextItemId() {
      return textItemId;
    }

    /**
     * <code>optional uint32 text_item_id = 12;</code>
     * @param value the textItemId to set
     * @return this
     */
    public TextJoinInfo setTextItemId(final int value) {
      bitField0_ |= 0x00000001;
      textItemId = value;
      return this;
    }

    /**
     * <code>optional uint32 text_item_config_id = 15;</code>
     * @return whether the textItemConfigId field is set
     */
    public boolean hasTextItemConfigId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 text_item_config_id = 15;</code>
     * @return this
     */
    public TextJoinInfo clearTextItemConfigId() {
      bitField0_ &= ~0x00000002;
      textItemConfigId = 0;
      return this;
    }

    /**
     * <code>optional uint32 text_item_config_id = 15;</code>
     * @return the textItemConfigId
     */
    public int getTextItemConfigId() {
      return textItemConfigId;
    }

    /**
     * <code>optional uint32 text_item_config_id = 15;</code>
     * @param value the textItemConfigId to set
     * @return this
     */
    public TextJoinInfo setTextItemConfigId(final int value) {
      bitField0_ |= 0x00000002;
      textItemConfigId = value;
      return this;
    }

    @Override
    public TextJoinInfo copyFrom(final TextJoinInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        textItemId = other.textItemId;
        textItemConfigId = other.textItemConfigId;
      }
      return this;
    }

    @Override
    public TextJoinInfo mergeFrom(final TextJoinInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasTextItemId()) {
        setTextItemId(other.textItemId);
      }
      if (other.hasTextItemConfigId()) {
        setTextItemConfigId(other.textItemConfigId);
      }
      return this;
    }

    @Override
    public TextJoinInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      textItemId = 0;
      textItemConfigId = 0;
      return this;
    }

    @Override
    public TextJoinInfo 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 TextJoinInfo)) {
        return false;
      }
      TextJoinInfo other = (TextJoinInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasTextItemId() || textItemId == other.textItemId)
        && (!hasTextItemConfigId() || textItemConfigId == other.textItemConfigId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(textItemId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt32NoTag(textItemConfigId);
      }
    }

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

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

    @Override
    public TextJoinInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1565189915:
          case -153409355: {
            if (input.isAtField(FieldNames.textItemId)) {
              if (!input.trySkipNullValue()) {
                textItemId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1448403459:
          case -1174236578: {
            if (input.isAtField(FieldNames.textItemConfigId)) {
              if (!input.trySkipNullValue()) {
                textItemConfigId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum TextJoinInfoFactory implements MessageFactory<TextJoinInfo> {
      INSTANCE;

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

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

      static final FieldName textItemConfigId = FieldName.forField("textItemConfigId", "text_item_config_id");
    }
  }
}
