// 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 item_id = 2;</code>
     */
    private int itemId;

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

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

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

    private BuyGoodsCsReq() {
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    @Override
    public BuyGoodsCsReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      itemId = 0;
      shopId = 0;
      goodsNum = 0;
      goodsId = 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_
        && (!hasItemId() || itemId == other.itemId)
        && (!hasShopId() || shopId == other.shopId)
        && (!hasGoodsNum() || goodsNum == other.goodsNum)
        && (!hasGoodsId() || goodsId == other.goodsId);
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(itemId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 72);
        output.writeUInt32NoTag(goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 96);
        output.writeUInt32NoTag(goodsId);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(itemId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(goodsId);
      }
      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 16: {
            // itemId
            itemId = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // shopId
            shopId = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 72) {
              break;
            }
          }
          case 72: {
            // goodsNum
            goodsNum = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 96) {
              break;
            }
          }
          case 96: {
            // goodsId
            goodsId = 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.itemId, itemId);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.shopId, shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.goodsNum, goodsNum);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.goodsId, goodsId);
      }
      output.endObject();
    }

    @Override
    public BuyGoodsCsReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -1178662002:
          case 2116204999: {
            if (input.isAtField(FieldNames.itemId)) {
              if (!input.trySkipNullValue()) {
                itemId = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -903151951:
          case 2067081988: {
            if (input.isAtField(FieldNames.shopId)) {
              if (!input.trySkipNullValue()) {
                shopId = 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 207037201:
          case 2123207332: {
            if (input.isAtField(FieldNames.goodsId)) {
              if (!input.trySkipNullValue()) {
                goodsId = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } 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 itemId = FieldName.forField("itemId", "item_id");

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

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

      static final FieldName goodsId = FieldName.forField("goodsId", "goods_id");
    }
  }
}
