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

    /**
     * <code>optional uint32 goods_id = 5;</code>
     */
    private int goodsId;

    /**
     * <code>optional uint32 server_entity_id = 6;</code>
     */
    private int serverEntityId;

    /**
     * <code>optional uint32 goods_num = 8;</code>
     */
    private int goodsNum;

    /**
     * <code>optional uint32 item_id = 13;</code>
     */
    private int itemId;

    /**
     * <code>optional uint32 shop_id = 15;</code>
     */
    private int shopId;

    private BuyGoodsCsReq() {
    }

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

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

    /**
     * <code>optional uint32 goods_id = 5;</code>
     * @return this
     */
    public BuyGoodsCsReq clearGoodsId() {
      bitField0_ &= ~0x00000001;
      goodsId = 0;
      return this;
    }

    /**
     * <code>optional uint32 goods_id = 5;</code>
     * @return the goodsId
     */
    public int getGoodsId() {
      return goodsId;
    }

    /**
     * <code>optional uint32 goods_id = 5;</code>
     * @param value the goodsId to set
     * @return this
     */
    public BuyGoodsCsReq setGoodsId(final int value) {
      bitField0_ |= 0x00000001;
      goodsId = value;
      return this;
    }

    /**
     * <code>optional uint32 server_entity_id = 6;</code>
     * @return whether the serverEntityId field is set
     */
    public boolean hasServerEntityId() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 server_entity_id = 6;</code>
     * @return this
     */
    public BuyGoodsCsReq clearServerEntityId() {
      bitField0_ &= ~0x00000002;
      serverEntityId = 0;
      return this;
    }

    /**
     * <code>optional uint32 server_entity_id = 6;</code>
     * @return the serverEntityId
     */
    public int getServerEntityId() {
      return serverEntityId;
    }

    /**
     * <code>optional uint32 server_entity_id = 6;</code>
     * @param value the serverEntityId to set
     * @return this
     */
    public BuyGoodsCsReq setServerEntityId(final int value) {
      bitField0_ |= 0x00000002;
      serverEntityId = value;
      return this;
    }

    /**
     * <code>optional uint32 goods_num = 8;</code>
     * @return whether the goodsNum field is set
     */
    public boolean hasGoodsNum() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 goods_num = 8;</code>
     * @return this
     */
    public BuyGoodsCsReq clearGoodsNum() {
      bitField0_ &= ~0x00000004;
      goodsNum = 0;
      return this;
    }

    /**
     * <code>optional uint32 goods_num = 8;</code>
     * @return the goodsNum
     */
    public int getGoodsNum() {
      return goodsNum;
    }

    /**
     * <code>optional uint32 goods_num = 8;</code>
     * @param value the goodsNum to set
     * @return this
     */
    public BuyGoodsCsReq setGoodsNum(final int value) {
      bitField0_ |= 0x00000004;
      goodsNum = value;
      return this;
    }

    /**
     * <code>optional uint32 item_id = 13;</code>
     * @return whether the itemId field is set
     */
    public boolean hasItemId() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 item_id = 13;</code>
     * @return this
     */
    public BuyGoodsCsReq clearItemId() {
      bitField0_ &= ~0x00000008;
      itemId = 0;
      return this;
    }

    /**
     * <code>optional uint32 item_id = 13;</code>
     * @return the itemId
     */
    public int getItemId() {
      return itemId;
    }

    /**
     * <code>optional uint32 item_id = 13;</code>
     * @param value the itemId to set
     * @return this
     */
    public BuyGoodsCsReq setItemId(final int value) {
      bitField0_ |= 0x00000008;
      itemId = value;
      return this;
    }

    /**
     * <code>optional uint32 shop_id = 15;</code>
     * @return whether the shopId field is set
     */
    public boolean hasShopId() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional uint32 shop_id = 15;</code>
     * @return this
     */
    public BuyGoodsCsReq clearShopId() {
      bitField0_ &= ~0x00000010;
      shopId = 0;
      return this;
    }

    /**
     * <code>optional uint32 shop_id = 15;</code>
     * @return the shopId
     */
    public int getShopId() {
      return shopId;
    }

    /**
     * <code>optional uint32 shop_id = 15;</code>
     * @param value the shopId to set
     * @return this
     */
    public BuyGoodsCsReq setShopId(final int value) {
      bitField0_ |= 0x00000010;
      shopId = value;
      return this;
    }

    @Override
    public BuyGoodsCsReq copyFrom(final BuyGoodsCsReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        goodsId = other.goodsId;
        serverEntityId = other.serverEntityId;
        goodsNum = other.goodsNum;
        itemId = other.itemId;
        shopId = other.shopId;
      }
      return this;
    }

    @Override
    public BuyGoodsCsReq mergeFrom(final BuyGoodsCsReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasGoodsId()) {
        setGoodsId(other.goodsId);
      }
      if (other.hasServerEntityId()) {
        setServerEntityId(other.serverEntityId);
      }
      if (other.hasGoodsNum()) {
        setGoodsNum(other.goodsNum);
      }
      if (other.hasItemId()) {
        setItemId(other.itemId);
      }
      if (other.hasShopId()) {
        setShopId(other.shopId);
      }
      return this;
    }

    @Override
    public BuyGoodsCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      goodsId = 0;
      serverEntityId = 0;
      goodsNum = 0;
      itemId = 0;
      shopId = 0;
      return this;
    }

    @Override
    public BuyGoodsCsReq 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 BuyGoodsCsReq)) {
        return false;
      }
      BuyGoodsCsReq other = (BuyGoodsCsReq) o;
      return bitField0_ == other.bitField0_
        && (!hasGoodsId() || goodsId == other.goodsId)
        && (!hasServerEntityId() || serverEntityId == other.serverEntityId)
        && (!hasGoodsNum() || goodsNum == other.goodsNum)
        && (!hasItemId() || itemId == other.itemId)
        && (!hasShopId() || shopId == other.shopId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(goodsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(serverEntityId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 104);
        output.writeUInt32NoTag(itemId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 120);
        output.writeUInt32NoTag(shopId);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(goodsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(serverEntityId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(itemId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(shopId);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public BuyGoodsCsReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 40: {
            // goodsId
            goodsId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // serverEntityId
            serverEntityId = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // goodsNum
            goodsNum = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 104) {
              break;
            }
          }
          case 104: {
            // itemId
            itemId = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 120) {
              break;
            }
          }
          case 120: {
            // shopId
            shopId = input.readUInt32();
            bitField0_ |= 0x00000010;
            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.goodsId, goodsId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.serverEntityId, serverEntityId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.goodsNum, goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.itemId, itemId);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.shopId, shopId);
      }
      output.endObject();
    }

    @Override
    public BuyGoodsCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 207037201:
          case 2123207332: {
            if (input.isAtField(FieldNames.goodsId)) {
              if (!input.trySkipNullValue()) {
                goodsId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1931796287:
          case 525013243: {
            if (input.isAtField(FieldNames.serverEntityId)) {
              if (!input.trySkipNullValue()) {
                serverEntityId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2123191376:
          case 1394923293: {
            if (input.isAtField(FieldNames.goodsNum)) {
              if (!input.trySkipNullValue()) {
                goodsNum = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1178662002:
          case 2116204999: {
            if (input.isAtField(FieldNames.itemId)) {
              if (!input.trySkipNullValue()) {
                itemId = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -903151951:
          case 2067081988: {
            if (input.isAtField(FieldNames.shopId)) {
              if (!input.trySkipNullValue()) {
                shopId = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum BuyGoodsCsReqFactory implements MessageFactory<BuyGoodsCsReq> {
      INSTANCE;

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

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

      static final FieldName serverEntityId = FieldName.forField("serverEntityId", "server_entity_id");

      static final FieldName goodsNum = FieldName.forField("goodsNum", "goods_num");

      static final FieldName itemId = FieldName.forField("itemId", "item_id");

      static final FieldName shopId = FieldName.forField("shopId", "shop_id");
    }
  }
}
