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

    /**
     * <code>optional uint32 add_coin = 6;</code>
     */
    private int addCoin;

    /**
     * <code>optional uint32 src_uid = 7;</code>
     */
    private int srcUid;

    /**
     * <code>optional uint32 sub_coin = 11;</code>
     */
    private int subCoin;

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

    private SocialEventServerCache() {
    }

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

    /**
     * <code>optional uint32 add_coin = 6;</code>
     * @return whether the addCoin field is set
     */
    public boolean hasAddCoin() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 add_coin = 6;</code>
     * @return this
     */
    public SocialEventServerCache clearAddCoin() {
      bitField0_ &= ~0x00000001;
      addCoin = 0;
      return this;
    }

    /**
     * <code>optional uint32 add_coin = 6;</code>
     * @return the addCoin
     */
    public int getAddCoin() {
      return addCoin;
    }

    /**
     * <code>optional uint32 add_coin = 6;</code>
     * @param value the addCoin to set
     * @return this
     */
    public SocialEventServerCache setAddCoin(final int value) {
      bitField0_ |= 0x00000001;
      addCoin = value;
      return this;
    }

    /**
     * <code>optional uint32 src_uid = 7;</code>
     * @return whether the srcUid field is set
     */
    public boolean hasSrcUid() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 src_uid = 7;</code>
     * @return this
     */
    public SocialEventServerCache clearSrcUid() {
      bitField0_ &= ~0x00000002;
      srcUid = 0;
      return this;
    }

    /**
     * <code>optional uint32 src_uid = 7;</code>
     * @return the srcUid
     */
    public int getSrcUid() {
      return srcUid;
    }

    /**
     * <code>optional uint32 src_uid = 7;</code>
     * @param value the srcUid to set
     * @return this
     */
    public SocialEventServerCache setSrcUid(final int value) {
      bitField0_ |= 0x00000002;
      srcUid = value;
      return this;
    }

    /**
     * <code>optional uint32 sub_coin = 11;</code>
     * @return whether the subCoin field is set
     */
    public boolean hasSubCoin() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 sub_coin = 11;</code>
     * @return this
     */
    public SocialEventServerCache clearSubCoin() {
      bitField0_ &= ~0x00000004;
      subCoin = 0;
      return this;
    }

    /**
     * <code>optional uint32 sub_coin = 11;</code>
     * @return the subCoin
     */
    public int getSubCoin() {
      return subCoin;
    }

    /**
     * <code>optional uint32 sub_coin = 11;</code>
     * @param value the subCoin to set
     * @return this
     */
    public SocialEventServerCache setSubCoin(final int value) {
      bitField0_ |= 0x00000004;
      subCoin = value;
      return this;
    }

    /**
     * <code>optional uint32 id = 12;</code>
     * @return whether the id field is set
     */
    public boolean hasId() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 id = 12;</code>
     * @return this
     */
    public SocialEventServerCache clearId() {
      bitField0_ &= ~0x00000008;
      id = 0;
      return this;
    }

    /**
     * <code>optional uint32 id = 12;</code>
     * @return the id
     */
    public int getId() {
      return id;
    }

    /**
     * <code>optional uint32 id = 12;</code>
     * @param value the id to set
     * @return this
     */
    public SocialEventServerCache setId(final int value) {
      bitField0_ |= 0x00000008;
      id = value;
      return this;
    }

    @Override
    public SocialEventServerCache copyFrom(final SocialEventServerCache other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        addCoin = other.addCoin;
        srcUid = other.srcUid;
        subCoin = other.subCoin;
        id = other.id;
      }
      return this;
    }

    @Override
    public SocialEventServerCache mergeFrom(final SocialEventServerCache other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasAddCoin()) {
        setAddCoin(other.addCoin);
      }
      if (other.hasSrcUid()) {
        setSrcUid(other.srcUid);
      }
      if (other.hasSubCoin()) {
        setSubCoin(other.subCoin);
      }
      if (other.hasId()) {
        setId(other.id);
      }
      return this;
    }

    @Override
    public SocialEventServerCache clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      addCoin = 0;
      srcUid = 0;
      subCoin = 0;
      id = 0;
      return this;
    }

    @Override
    public SocialEventServerCache 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 SocialEventServerCache)) {
        return false;
      }
      SocialEventServerCache other = (SocialEventServerCache) o;
      return bitField0_ == other.bitField0_
        && (!hasAddCoin() || addCoin == other.addCoin)
        && (!hasSrcUid() || srcUid == other.srcUid)
        && (!hasSubCoin() || subCoin == other.subCoin)
        && (!hasId() || id == other.id);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(addCoin);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 56);
        output.writeUInt32NoTag(srcUid);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 88);
        output.writeUInt32NoTag(subCoin);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(id);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(addCoin);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(srcUid);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(subCoin);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(id);
      }
      return size;
    }

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

    @Override
    public SocialEventServerCache mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1149082926:
          case -1236325521: {
            if (input.isAtField(FieldNames.addCoin)) {
              if (!input.trySkipNullValue()) {
                addCoin = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -894299188:
          case -1953161355: {
            if (input.isAtField(FieldNames.srcUid)) {
              if (!input.trySkipNullValue()) {
                srcUid = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1869037327:
          case -2080075472: {
            if (input.isAtField(FieldNames.subCoin)) {
              if (!input.trySkipNullValue()) {
                subCoin = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 3355: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum SocialEventServerCacheFactory implements MessageFactory<SocialEventServerCache> {
      INSTANCE;

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

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

      static final FieldName srcUid = FieldName.forField("srcUid", "src_uid");

      static final FieldName subCoin = FieldName.forField("subCoin", "sub_coin");

      static final FieldName id = FieldName.forField("id");
    }
  }
}
