// Code generated by protocol buffer compiler. Do not edit!
package emu.nebula.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.RepeatedByte;

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

    /**
     * <code>optional int64 RefreshTime = 2;</code>
     */
    private long refreshTime;

    /**
     * <code>optional uint32 ShopId = 1;</code>
     */
    private int shopId;

    /**
     * <code>optional uint32 GoodsId = 3;</code>
     */
    private int goodsId;

    /**
     * <code>optional uint32 Number = 4;</code>
     */
    private int number;

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    private ResidentShopPurchaseReq() {
    }

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

    /**
     * <code>optional int64 RefreshTime = 2;</code>
     * @return whether the refreshTime field is set
     */
    public boolean hasRefreshTime() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional int64 RefreshTime = 2;</code>
     * @return this
     */
    public ResidentShopPurchaseReq clearRefreshTime() {
      bitField0_ &= ~0x00000001;
      refreshTime = 0L;
      return this;
    }

    /**
     * <code>optional int64 RefreshTime = 2;</code>
     * @return the refreshTime
     */
    public long getRefreshTime() {
      return refreshTime;
    }

    /**
     * <code>optional int64 RefreshTime = 2;</code>
     * @param value the refreshTime to set
     * @return this
     */
    public ResidentShopPurchaseReq setRefreshTime(final long value) {
      bitField0_ |= 0x00000001;
      refreshTime = value;
      return this;
    }

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

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

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

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

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

    /**
     * <code>optional uint32 GoodsId = 3;</code>
     * @return this
     */
    public ResidentShopPurchaseReq clearGoodsId() {
      bitField0_ &= ~0x00000004;
      goodsId = 0;
      return this;
    }

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

    /**
     * <code>optional uint32 GoodsId = 3;</code>
     * @param value the goodsId to set
     * @return this
     */
    public ResidentShopPurchaseReq setGoodsId(final int value) {
      bitField0_ |= 0x00000004;
      goodsId = value;
      return this;
    }

    /**
     * <code>optional uint32 Number = 4;</code>
     * @return whether the number field is set
     */
    public boolean hasNumber() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 Number = 4;</code>
     * @return this
     */
    public ResidentShopPurchaseReq clearNumber() {
      bitField0_ &= ~0x00000008;
      number = 0;
      return this;
    }

    /**
     * <code>optional uint32 Number = 4;</code>
     * @return the number
     */
    public int getNumber() {
      return number;
    }

    /**
     * <code>optional uint32 Number = 4;</code>
     * @param value the number to set
     * @return this
     */
    public ResidentShopPurchaseReq setNumber(final int value) {
      bitField0_ |= 0x00000008;
      number = value;
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ResidentShopPurchaseReq clearNextPackage() {
      bitField0_ &= ~0x00000010;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000010;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public ResidentShopPurchaseReq addNextPackage(final byte value) {
      bitField0_ |= 0x00000010;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public ResidentShopPurchaseReq addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000010;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public ResidentShopPurchaseReq setNextPackage(final byte... values) {
      bitField0_ |= 0x00000010;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public ResidentShopPurchaseReq copyFrom(final ResidentShopPurchaseReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        refreshTime = other.refreshTime;
        shopId = other.shopId;
        goodsId = other.goodsId;
        number = other.number;
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ResidentShopPurchaseReq mergeFrom(final ResidentShopPurchaseReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasRefreshTime()) {
        setRefreshTime(other.refreshTime);
      }
      if (other.hasShopId()) {
        setShopId(other.shopId);
      }
      if (other.hasGoodsId()) {
        setGoodsId(other.goodsId);
      }
      if (other.hasNumber()) {
        setNumber(other.number);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ResidentShopPurchaseReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      refreshTime = 0L;
      shopId = 0;
      goodsId = 0;
      number = 0;
      nextPackage.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ResidentShopPurchaseReq)) {
        return false;
      }
      ResidentShopPurchaseReq other = (ResidentShopPurchaseReq) o;
      return bitField0_ == other.bitField0_
        && (!hasRefreshTime() || refreshTime == other.refreshTime)
        && (!hasShopId() || shopId == other.shopId)
        && (!hasGoodsId() || goodsId == other.goodsId)
        && (!hasNumber() || number == other.number)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeInt64NoTag(refreshTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(goodsId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(number);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeInt64SizeNoTag(refreshTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(goodsId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(number);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ResidentShopPurchaseReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // refreshTime
            refreshTime = input.readInt64();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // shopId
            shopId = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // goodsId
            goodsId = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // number
            number = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            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.writeInt64(FieldNames.refreshTime, refreshTime);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.shopId, shopId);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.goodsId, goodsId);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.number, number);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public ResidentShopPurchaseReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 280566824: {
            if (input.isAtField(FieldNames.refreshTime)) {
              if (!input.trySkipNullValue()) {
                refreshTime = input.readInt64();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1819284783: {
            if (input.isAtField(FieldNames.shopId)) {
              if (!input.trySkipNullValue()) {
                shopId = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1871690481: {
            if (input.isAtField(FieldNames.goodsId)) {
              if (!input.trySkipNullValue()) {
                goodsId = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1950496919: {
            if (input.isAtField(FieldNames.number)) {
              if (!input.trySkipNullValue()) {
                number = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ResidentShopPurchaseReqFactory implements MessageFactory<ResidentShopPurchaseReq> {
      INSTANCE;

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

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

      static final FieldName shopId = FieldName.forField("ShopId");

      static final FieldName goodsId = FieldName.forField("GoodsId");

      static final FieldName number = FieldName.forField("Number");

      static final FieldName nextPackage = FieldName.forField("NextPackage");
    }
  }

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

    /**
     * <code>optional uint32 PurchasedNumber = 3;</code>
     */
    private int purchasedNumber;

    /**
     * <code>optional bool IsRefresh = 1;</code>
     */
    private boolean isRefresh;

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     */
    private final Public.ResidentShop shop = Public.ResidentShop.newInstance();

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     */
    private final Public.ChangeInfo change = Public.ChangeInfo.newInstance();

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     */
    private final RepeatedByte nextPackage = RepeatedByte.newEmptyInstance();

    private ResidentShopPurchaseResp() {
    }

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

    /**
     * <code>optional uint32 PurchasedNumber = 3;</code>
     * @return whether the purchasedNumber field is set
     */
    public boolean hasPurchasedNumber() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 PurchasedNumber = 3;</code>
     * @return this
     */
    public ResidentShopPurchaseResp clearPurchasedNumber() {
      bitField0_ &= ~0x00000001;
      purchasedNumber = 0;
      return this;
    }

    /**
     * <code>optional uint32 PurchasedNumber = 3;</code>
     * @return the purchasedNumber
     */
    public int getPurchasedNumber() {
      return purchasedNumber;
    }

    /**
     * <code>optional uint32 PurchasedNumber = 3;</code>
     * @param value the purchasedNumber to set
     * @return this
     */
    public ResidentShopPurchaseResp setPurchasedNumber(final int value) {
      bitField0_ |= 0x00000001;
      purchasedNumber = value;
      return this;
    }

    /**
     * <code>optional bool IsRefresh = 1;</code>
     * @return whether the isRefresh field is set
     */
    public boolean hasIsRefresh() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional bool IsRefresh = 1;</code>
     * @return this
     */
    public ResidentShopPurchaseResp clearIsRefresh() {
      bitField0_ &= ~0x00000002;
      isRefresh = false;
      return this;
    }

    /**
     * <code>optional bool IsRefresh = 1;</code>
     * @return the isRefresh
     */
    public boolean getIsRefresh() {
      return isRefresh;
    }

    /**
     * <code>optional bool IsRefresh = 1;</code>
     * @param value the isRefresh to set
     * @return this
     */
    public ResidentShopPurchaseResp setIsRefresh(final boolean value) {
      bitField0_ |= 0x00000002;
      isRefresh = value;
      return this;
    }

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     * @return whether the shop field is set
     */
    public boolean hasShop() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     * @return this
     */
    public ResidentShopPurchaseResp clearShop() {
      bitField0_ &= ~0x00000004;
      shop.clear();
      return this;
    }

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableShop()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.ResidentShop getShop() {
      return shop;
    }

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public Public.ResidentShop getMutableShop() {
      bitField0_ |= 0x00000004;
      return shop;
    }

    /**
     * <code>optional .ResidentShop Shop = 2;</code>
     * @param value the shop to set
     * @return this
     */
    public ResidentShopPurchaseResp setShop(final Public.ResidentShop value) {
      bitField0_ |= 0x00000004;
      shop.copyFrom(value);
      return this;
    }

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     * @return whether the change field is set
     */
    public boolean hasChange() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     * @return this
     */
    public ResidentShopPurchaseResp clearChange() {
      bitField0_ &= ~0x00000008;
      change.clear();
      return this;
    }

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableChange()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.ChangeInfo getChange() {
      return change;
    }

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public Public.ChangeInfo getMutableChange() {
      bitField0_ |= 0x00000008;
      return change;
    }

    /**
     * <code>optional .ChangeInfo Change = 4;</code>
     * @param value the change to set
     * @return this
     */
    public ResidentShopPurchaseResp setChange(final Public.ChangeInfo value) {
      bitField0_ |= 0x00000008;
      change.copyFrom(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return whether the nextPackage field is set
     */
    public boolean hasNextPackage() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ResidentShopPurchaseResp clearNextPackage() {
      bitField0_ &= ~0x00000010;
      nextPackage.clear();
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object without modifying any has state.
     * The returned object should not be modified and be treated as read-only.
     *
     * Use {@link #getMutableNextPackage()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedByte getNextPackage() {
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     *
     * This method returns the internal storage object and sets the corresponding
     * has state. The returned object will become part of this message and its
     * contents may be modified as long as the has state is not cleared.
     *
     * @return internal storage object for modifications
     */
    public RepeatedByte getMutableNextPackage() {
      bitField0_ |= 0x00000010;
      return nextPackage;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param value the nextPackage to add
     * @return this
     */
    public ResidentShopPurchaseResp addNextPackage(final byte value) {
      bitField0_ |= 0x00000010;
      nextPackage.add(value);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to add
     * @return this
     */
    public ResidentShopPurchaseResp addAllNextPackage(final byte... values) {
      bitField0_ |= 0x00000010;
      nextPackage.addAll(values);
      return this;
    }

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @param values the nextPackage to set
     * @return this
     */
    public ResidentShopPurchaseResp setNextPackage(final byte... values) {
      bitField0_ |= 0x00000010;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public ResidentShopPurchaseResp copyFrom(final ResidentShopPurchaseResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        purchasedNumber = other.purchasedNumber;
        isRefresh = other.isRefresh;
        shop.copyFrom(other.shop);
        change.copyFrom(other.change);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ResidentShopPurchaseResp mergeFrom(final ResidentShopPurchaseResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasPurchasedNumber()) {
        setPurchasedNumber(other.purchasedNumber);
      }
      if (other.hasIsRefresh()) {
        setIsRefresh(other.isRefresh);
      }
      if (other.hasShop()) {
        getMutableShop().mergeFrom(other.shop);
      }
      if (other.hasChange()) {
        getMutableChange().mergeFrom(other.change);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public ResidentShopPurchaseResp clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      purchasedNumber = 0;
      isRefresh = false;
      shop.clear();
      change.clear();
      nextPackage.clear();
      return this;
    }

    @Override
    public ResidentShopPurchaseResp clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      shop.clearQuick();
      change.clearQuick();
      nextPackage.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ResidentShopPurchaseResp)) {
        return false;
      }
      ResidentShopPurchaseResp other = (ResidentShopPurchaseResp) o;
      return bitField0_ == other.bitField0_
        && (!hasPurchasedNumber() || purchasedNumber == other.purchasedNumber)
        && (!hasIsRefresh() || isRefresh == other.isRefresh)
        && (!hasShop() || shop.equals(other.shop))
        && (!hasChange() || change.equals(other.change))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(purchasedNumber);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 8);
        output.writeBoolNoTag(isRefresh);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 18);
        output.writeMessageNoTag(shop);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 34);
        output.writeMessageNoTag(change);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(purchasedNumber);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 2;
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(shop);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeMessageSizeNoTag(change);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ResidentShopPurchaseResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 24: {
            // purchasedNumber
            purchasedNumber = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 8) {
              break;
            }
          }
          case 8: {
            // isRefresh
            isRefresh = input.readBool();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 18) {
              break;
            }
          }
          case 18: {
            // shop
            input.readMessage(shop);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 34) {
              break;
            }
          }
          case 34: {
            // change
            input.readMessage(change);
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            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.purchasedNumber, purchasedNumber);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBool(FieldNames.isRefresh, isRefresh);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.shop, shop);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeMessage(FieldNames.change, change);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public ResidentShopPurchaseResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 1475882124: {
            if (input.isAtField(FieldNames.purchasedNumber)) {
              if (!input.trySkipNullValue()) {
                purchasedNumber = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1785333199: {
            if (input.isAtField(FieldNames.isRefresh)) {
              if (!input.trySkipNullValue()) {
                isRefresh = input.readBool();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2576150: {
            if (input.isAtField(FieldNames.shop)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(shop);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2017198032: {
            if (input.isAtField(FieldNames.change)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(change);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ResidentShopPurchaseRespFactory implements MessageFactory<ResidentShopPurchaseResp> {
      INSTANCE;

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

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

      static final FieldName isRefresh = FieldName.forField("IsRefresh");

      static final FieldName shop = FieldName.forField("Shop");

      static final FieldName change = FieldName.forField("Change");

      static final FieldName nextPackage = FieldName.forField("NextPackage");
    }
  }
}
