// 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;
import us.hebi.quickbuf.RepeatedInt;
import us.hebi.quickbuf.RepeatedMessage;

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

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

    /**
     * <code>repeated uint32 ShopIds = 1;</code>
     */
    private final RepeatedInt shopIds = RepeatedInt.newEmptyInstance();

    private ResidentShopGetReq() {
    }

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

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ResidentShopGetReq clearNextPackage() {
      bitField0_ &= ~0x00000001;
      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_ |= 0x00000001;
      return nextPackage;
    }

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

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

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

    /**
     * <code>repeated uint32 ShopIds = 1;</code>
     * @return whether the shopIds field is set
     */
    public boolean hasShopIds() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated uint32 ShopIds = 1;</code>
     * @return this
     */
    public ResidentShopGetReq clearShopIds() {
      bitField0_ &= ~0x00000002;
      shopIds.clear();
      return this;
    }

    /**
     * <code>repeated uint32 ShopIds = 1;</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 #getMutableShopIds()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedInt getShopIds() {
      return shopIds;
    }

    /**
     * <code>repeated uint32 ShopIds = 1;</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 RepeatedInt getMutableShopIds() {
      bitField0_ |= 0x00000002;
      return shopIds;
    }

    /**
     * <code>repeated uint32 ShopIds = 1;</code>
     * @param value the shopIds to add
     * @return this
     */
    public ResidentShopGetReq addShopIds(final int value) {
      bitField0_ |= 0x00000002;
      shopIds.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 ShopIds = 1;</code>
     * @param values the shopIds to add
     * @return this
     */
    public ResidentShopGetReq addAllShopIds(final int... values) {
      bitField0_ |= 0x00000002;
      shopIds.addAll(values);
      return this;
    }

    @Override
    public ResidentShopGetReq copyFrom(final ResidentShopGetReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        nextPackage.copyFrom(other.nextPackage);
        shopIds.copyFrom(other.shopIds);
      }
      return this;
    }

    @Override
    public ResidentShopGetReq mergeFrom(final ResidentShopGetReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasShopIds()) {
        getMutableShopIds().addAll(other.shopIds);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ResidentShopGetReq)) {
        return false;
      }
      ResidentShopGetReq other = (ResidentShopGetReq) o;
      return bitField0_ == other.bitField0_
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasShopIds() || shopIds.equals(other.shopIds));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < shopIds.length(); i++) {
          output.writeRawByte((byte) 8);
          output.writeUInt32NoTag(shopIds.array()[i]);
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += (1 * shopIds.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(shopIds);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ResidentShopGetReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // shopIds [packed=true]
            input.readPackedUInt32(shopIds, tag);
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
          case 8: {
            // shopIds [packed=false]
            tag = input.readRepeatedUInt32(shopIds, tag);
            bitField0_ |= 0x00000002;
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRepeatedUInt32(FieldNames.shopIds, shopIds);
      }
      output.endObject();
    }

    @Override
    public ResidentShopGetReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -563253310: {
            if (input.isAtField(FieldNames.shopIds)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(shopIds);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ResidentShopGetReqFactory implements MessageFactory<ResidentShopGetReq> {
      INSTANCE;

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

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

      static final FieldName shopIds = FieldName.forField("ShopIds");
    }
  }

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

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

    /**
     * <code>repeated .ResidentShop Shops = 1;</code>
     */
    private final RepeatedMessage<Public.ResidentShop> shops = RepeatedMessage.newEmptyInstance(Public.ResidentShop.getFactory());

    private ResidentShopGetResp() {
    }

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

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

    /**
     * <code>optional bytes NextPackage = 2047;</code>
     * @return this
     */
    public ResidentShopGetResp clearNextPackage() {
      bitField0_ &= ~0x00000001;
      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_ |= 0x00000001;
      return nextPackage;
    }

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

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

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

    /**
     * <code>repeated .ResidentShop Shops = 1;</code>
     * @return whether the shops field is set
     */
    public boolean hasShops() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>repeated .ResidentShop Shops = 1;</code>
     * @return this
     */
    public ResidentShopGetResp clearShops() {
      bitField0_ &= ~0x00000002;
      shops.clear();
      return this;
    }

    /**
     * <code>repeated .ResidentShop Shops = 1;</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 #getMutableShops()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<Public.ResidentShop> getShops() {
      return shops;
    }

    /**
     * <code>repeated .ResidentShop Shops = 1;</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 RepeatedMessage<Public.ResidentShop> getMutableShops() {
      bitField0_ |= 0x00000002;
      return shops;
    }

    /**
     * <code>repeated .ResidentShop Shops = 1;</code>
     * @param value the shops to add
     * @return this
     */
    public ResidentShopGetResp addShops(final Public.ResidentShop value) {
      bitField0_ |= 0x00000002;
      shops.add(value);
      return this;
    }

    /**
     * <code>repeated .ResidentShop Shops = 1;</code>
     * @param values the shops to add
     * @return this
     */
    public ResidentShopGetResp addAllShops(final Public.ResidentShop... values) {
      bitField0_ |= 0x00000002;
      shops.addAll(values);
      return this;
    }

    @Override
    public ResidentShopGetResp copyFrom(final ResidentShopGetResp other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        nextPackage.copyFrom(other.nextPackage);
        shops.copyFrom(other.shops);
      }
      return this;
    }

    @Override
    public ResidentShopGetResp mergeFrom(final ResidentShopGetResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasShops()) {
        getMutableShops().addAll(other.shops);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof ResidentShopGetResp)) {
        return false;
      }
      ResidentShopGetResp other = (ResidentShopGetResp) o;
      return bitField0_ == other.bitField0_
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasShops() || shops.equals(other.shops));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        for (int i = 0; i < shops.length(); i++) {
          output.writeRawByte((byte) 10);
          output.writeMessageNoTag(shops.get(i));
        }
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += (1 * shops.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(shops);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public ResidentShopGetResp mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // shops
            tag = input.readRepeatedMessage(shops, tag);
            bitField0_ |= 0x00000002;
            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.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRepeatedMessage(FieldNames.shops, shops);
      }
      output.endObject();
    }

    @Override
    public ResidentShopGetResp mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 79860765: {
            if (input.isAtField(FieldNames.shops)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(shops);
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum ResidentShopGetRespFactory implements MessageFactory<ResidentShopGetResp> {
      INSTANCE;

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

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

      static final FieldName shops = FieldName.forField("Shops");
    }
  }
}
