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

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

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

    /**
     * <code>optional string value = 2;</code>
     */
    private final Utf8String value_ = Utf8String.newEmptyInstance();

    private ClientUploadData() {
    }

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

    /**
     * <code>optional string tag = 1;</code>
     * @return whether the tag_ field is set
     */
    public boolean hasTag() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional string tag = 1;</code>
     * @return this
     */
    public ClientUploadData clearTag() {
      bitField0_ &= ~0x00000001;
      tag_.clear();
      return this;
    }

    /**
     * <code>optional string tag = 1;</code>
     * @return the tag_
     */
    public String getTag() {
      return tag_.getString();
    }

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

    /**
     * <code>optional string tag = 1;</code>
     * @return internal {@code Utf8String} representation of tag_ for modifications
     */
    public Utf8String getMutableTagBytes() {
      bitField0_ |= 0x00000001;
      return this.tag_;
    }

    /**
     * <code>optional string tag = 1;</code>
     * @param value the tag_ to set
     * @return this
     */
    public ClientUploadData setTag(final CharSequence value) {
      bitField0_ |= 0x00000001;
      tag_.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string tag = 1;</code>
     * @param value the tag_ to set
     * @return this
     */
    public ClientUploadData setTag(final Utf8String value) {
      bitField0_ |= 0x00000001;
      tag_.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string value = 2;</code>
     * @return whether the value_ field is set
     */
    public boolean hasValue() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional string value = 2;</code>
     * @return this
     */
    public ClientUploadData clearValue() {
      bitField0_ &= ~0x00000002;
      value_.clear();
      return this;
    }

    /**
     * <code>optional string value = 2;</code>
     * @return the value_
     */
    public String getValue() {
      return value_.getString();
    }

    /**
     * <code>optional string value = 2;</code>
     * @return internal {@code Utf8String} representation of value_ for reading
     */
    public Utf8String getValueBytes() {
      return this.value_;
    }

    /**
     * <code>optional string value = 2;</code>
     * @return internal {@code Utf8String} representation of value_ for modifications
     */
    public Utf8String getMutableValueBytes() {
      bitField0_ |= 0x00000002;
      return this.value_;
    }

    /**
     * <code>optional string value = 2;</code>
     * @param value the value_ to set
     * @return this
     */
    public ClientUploadData setValue(final CharSequence value) {
      bitField0_ |= 0x00000002;
      value_.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string value = 2;</code>
     * @param value the value_ to set
     * @return this
     */
    public ClientUploadData setValue(final Utf8String value) {
      bitField0_ |= 0x00000002;
      value_.copyFrom(value);
      return this;
    }

    @Override
    public ClientUploadData copyFrom(final ClientUploadData other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        tag_.copyFrom(other.tag_);
        value_.copyFrom(other.value_);
      }
      return this;
    }

    @Override
    public ClientUploadData mergeFrom(final ClientUploadData other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasTag()) {
        getMutableTagBytes().copyFrom(other.tag_);
      }
      if (other.hasValue()) {
        getMutableValueBytes().copyFrom(other.value_);
      }
      return this;
    }

    @Override
    public ClientUploadData clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      tag_.clear();
      value_.clear();
      return this;
    }

    @Override
    public ClientUploadData clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      tag_.clear();
      value_.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ClientUploadData)) {
        return false;
      }
      ClientUploadData other = (ClientUploadData) o;
      return bitField0_ == other.bitField0_
        && (!hasTag() || tag_.equals(other.tag_))
        && (!hasValue() || value_.equals(other.value_));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(tag_);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 18);
        output.writeStringNoTag(value_);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public ClientUploadData mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 10: {
            // tag_
            input.readString(tag_);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // value_
            input.readString(value_);
            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.writeString(FieldNames.tag_, tag_);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeString(FieldNames.value_, value_);
      }
      output.endObject();
    }

    @Override
    public ClientUploadData mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 114586: {
            if (input.isAtField(FieldNames.tag_)) {
              if (!input.trySkipNullValue()) {
                input.readString(tag_);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 111972721: {
            if (input.isAtField(FieldNames.value_)) {
              if (!input.trySkipNullValue()) {
                input.readString(value_);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ClientUploadDataFactory implements MessageFactory<ClientUploadData> {
      INSTANCE;

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

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

      static final FieldName value_ = FieldName.forField("value");
    }
  }
}
