// 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.RepeatedMessage;

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

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

    /**
     * <code>optional uint32 Times = 2;</code>
     */
    private int times;

    /**
     * <code>optional .Events Events = 15;</code>
     */
    private final Public.Events events = Public.Events.newInstance();

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

    private CharGemInstanceSweepReq() {
    }

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

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

    /**
     * <code>optional uint32 Id = 1;</code>
     * @return this
     */
    public CharGemInstanceSweepReq clearId() {
      bitField0_ &= ~0x00000001;
      id = 0;
      return this;
    }

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

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

    /**
     * <code>optional uint32 Times = 2;</code>
     * @return whether the times field is set
     */
    public boolean hasTimes() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 Times = 2;</code>
     * @return this
     */
    public CharGemInstanceSweepReq clearTimes() {
      bitField0_ &= ~0x00000002;
      times = 0;
      return this;
    }

    /**
     * <code>optional uint32 Times = 2;</code>
     * @return the times
     */
    public int getTimes() {
      return times;
    }

    /**
     * <code>optional uint32 Times = 2;</code>
     * @param value the times to set
     * @return this
     */
    public CharGemInstanceSweepReq setTimes(final int value) {
      bitField0_ |= 0x00000002;
      times = value;
      return this;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @return whether the events field is set
     */
    public boolean hasEvents() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @return this
     */
    public CharGemInstanceSweepReq clearEvents() {
      bitField0_ &= ~0x00000004;
      events.clear();
      return this;
    }

    /**
     * <code>optional .Events Events = 15;</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 #getMutableEvents()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.Events getEvents() {
      return events;
    }

    /**
     * <code>optional .Events Events = 15;</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.Events getMutableEvents() {
      bitField0_ |= 0x00000004;
      return events;
    }

    /**
     * <code>optional .Events Events = 15;</code>
     * @param value the events to set
     * @return this
     */
    public CharGemInstanceSweepReq setEvents(final Public.Events value) {
      bitField0_ |= 0x00000004;
      events.copyFrom(value);
      return this;
    }

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

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

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

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

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

    @Override
    public CharGemInstanceSweepReq copyFrom(final CharGemInstanceSweepReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        id = other.id;
        times = other.times;
        events.copyFrom(other.events);
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public CharGemInstanceSweepReq mergeFrom(final CharGemInstanceSweepReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasId()) {
        setId(other.id);
      }
      if (other.hasTimes()) {
        setTimes(other.times);
      }
      if (other.hasEvents()) {
        getMutableEvents().mergeFrom(other.events);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public CharGemInstanceSweepReq clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      id = 0;
      times = 0;
      events.clear();
      nextPackage.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof CharGemInstanceSweepReq)) {
        return false;
      }
      CharGemInstanceSweepReq other = (CharGemInstanceSweepReq) o;
      return bitField0_ == other.bitField0_
        && (!hasId() || id == other.id)
        && (!hasTimes() || times == other.times)
        && (!hasEvents() || events.equals(other.events))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(times);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 122);
        output.writeMessageNoTag(events);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
    }

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

    @Override
    @SuppressWarnings("fallthrough")
    public CharGemInstanceSweepReq mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // id
            id = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 16) {
              break;
            }
          }
          case 16: {
            // times
            times = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 122) {
              break;
            }
          }
          case 122: {
            // events
            input.readMessage(events);
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 16378) {
              break;
            }
          }
          case 16378: {
            // nextPackage
            input.readBytes(nextPackage);
            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.id, id);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.times, times);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeMessage(FieldNames.events, events);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      output.endObject();
    }

    @Override
    public CharGemInstanceSweepReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2363: {
            if (input.isAtField(FieldNames.id)) {
              if (!input.trySkipNullValue()) {
                id = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 80811814: {
            if (input.isAtField(FieldNames.times)) {
              if (!input.trySkipNullValue()) {
                times = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2087505209: {
            if (input.isAtField(FieldNames.events)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(events);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -2082324045: {
            if (input.isAtField(FieldNames.nextPackage)) {
              if (!input.trySkipNullValue()) {
                input.readBytes(nextPackage);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum CharGemInstanceSweepReqFactory implements MessageFactory<CharGemInstanceSweepReq> {
      INSTANCE;

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

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

      static final FieldName times = FieldName.forField("Times");

      static final FieldName events = FieldName.forField("Events");

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

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

    /**
     * <code>optional uint32 Exp = 2;</code>
     */
    private int exp;

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

    /**
     * <code>repeated .ItemTpl AwardItems = 1;</code>
     */
    private final RepeatedMessage<Public.ItemTpl> awardItems = RepeatedMessage.newEmptyInstance(Public.ItemTpl.getFactory());

    private CharGemInstanceSweepReward() {
    }

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

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

    /**
     * <code>optional uint32 Exp = 2;</code>
     * @return this
     */
    public CharGemInstanceSweepReward clearExp() {
      bitField0_ &= ~0x00000001;
      exp = 0;
      return this;
    }

    /**
     * <code>optional uint32 Exp = 2;</code>
     * @return the exp
     */
    public int getExp() {
      return exp;
    }

    /**
     * <code>optional uint32 Exp = 2;</code>
     * @param value the exp to set
     * @return this
     */
    public CharGemInstanceSweepReward setExp(final int value) {
      bitField0_ |= 0x00000001;
      exp = value;
      return this;
    }

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

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

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

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

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

    /**
     * <code>repeated .ItemTpl AwardItems = 1;</code>
     * @return whether the awardItems field is set
     */
    public boolean hasAwardItems() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .ItemTpl AwardItems = 1;</code>
     * @return this
     */
    public CharGemInstanceSweepReward clearAwardItems() {
      bitField0_ &= ~0x00000004;
      awardItems.clear();
      return this;
    }

    /**
     * <code>repeated .ItemTpl AwardItems = 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 #getMutableAwardItems()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<Public.ItemTpl> getAwardItems() {
      return awardItems;
    }

    /**
     * <code>repeated .ItemTpl AwardItems = 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.ItemTpl> getMutableAwardItems() {
      bitField0_ |= 0x00000004;
      return awardItems;
    }

    /**
     * <code>repeated .ItemTpl AwardItems = 1;</code>
     * @param value the awardItems to add
     * @return this
     */
    public CharGemInstanceSweepReward addAwardItems(final Public.ItemTpl value) {
      bitField0_ |= 0x00000004;
      awardItems.add(value);
      return this;
    }

    /**
     * <code>repeated .ItemTpl AwardItems = 1;</code>
     * @param values the awardItems to add
     * @return this
     */
    public CharGemInstanceSweepReward addAllAwardItems(final Public.ItemTpl... values) {
      bitField0_ |= 0x00000004;
      awardItems.addAll(values);
      return this;
    }

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

    @Override
    public CharGemInstanceSweepReward mergeFrom(final CharGemInstanceSweepReward other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasExp()) {
        setExp(other.exp);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasAwardItems()) {
        getMutableAwardItems().addAll(other.awardItems);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof CharGemInstanceSweepReward)) {
        return false;
      }
      CharGemInstanceSweepReward other = (CharGemInstanceSweepReward) o;
      return bitField0_ == other.bitField0_
        && (!hasExp() || exp == other.exp)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasAwardItems() || awardItems.equals(other.awardItems));
    }

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

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

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

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

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

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

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

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

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

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

    private enum CharGemInstanceSweepRewardFactory implements MessageFactory<CharGemInstanceSweepReward> {
      INSTANCE;

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

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

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

      static final FieldName awardItems = FieldName.forField("AwardItems");
    }
  }

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

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

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

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 2;</code>
     */
    private final RepeatedMessage<CharGemInstanceSweepReward> rewards = RepeatedMessage.newEmptyInstance(CharGemInstanceSweepReward.getFactory());

    private CharGemInstanceSweepResp() {
    }

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

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

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

    /**
     * <code>optional .ChangeInfo Change = 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 #getMutableChange()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public Public.ChangeInfo getChange() {
      return change;
    }

    /**
     * <code>optional .ChangeInfo Change = 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 Public.ChangeInfo getMutableChange() {
      bitField0_ |= 0x00000001;
      return change;
    }

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

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

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

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

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

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

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 2;</code>
     * @return whether the rewards field is set
     */
    public boolean hasRewards() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 2;</code>
     * @return this
     */
    public CharGemInstanceSweepResp clearRewards() {
      bitField0_ &= ~0x00000004;
      rewards.clear();
      return this;
    }

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 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 #getMutableRewards()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<CharGemInstanceSweepReward> getRewards() {
      return rewards;
    }

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 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 RepeatedMessage<CharGemInstanceSweepReward> getMutableRewards() {
      bitField0_ |= 0x00000004;
      return rewards;
    }

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 2;</code>
     * @param value the rewards to add
     * @return this
     */
    public CharGemInstanceSweepResp addRewards(final CharGemInstanceSweepReward value) {
      bitField0_ |= 0x00000004;
      rewards.add(value);
      return this;
    }

    /**
     * <code>repeated .CharGemInstanceSweepReward Rewards = 2;</code>
     * @param values the rewards to add
     * @return this
     */
    public CharGemInstanceSweepResp addAllRewards(final CharGemInstanceSweepReward... values) {
      bitField0_ |= 0x00000004;
      rewards.addAll(values);
      return this;
    }

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

    @Override
    public CharGemInstanceSweepResp mergeFrom(final CharGemInstanceSweepResp other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasChange()) {
        getMutableChange().mergeFrom(other.change);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasRewards()) {
        getMutableRewards().addAll(other.rewards);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof CharGemInstanceSweepResp)) {
        return false;
      }
      CharGemInstanceSweepResp other = (CharGemInstanceSweepResp) o;
      return bitField0_ == other.bitField0_
        && (!hasChange() || change.equals(other.change))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasRewards() || rewards.equals(other.rewards));
    }

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

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

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

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

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

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

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

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

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

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

    private enum CharGemInstanceSweepRespFactory implements MessageFactory<CharGemInstanceSweepResp> {
      INSTANCE;

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

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

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

      static final FieldName rewards = FieldName.forField("Rewards");
    }
  }
}
