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

    /**
     * <code>optional uint32 Idx = 1;</code>
     */
    private int idx;

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

    /**
     * <code>repeated .StoryOptions Major = 2;</code>
     */
    private final RepeatedMessage<StoryOptions> major = RepeatedMessage.newEmptyInstance(StoryOptions.getFactory());

    /**
     * <code>repeated .StoryOptions Personality = 3;</code>
     */
    private final RepeatedMessage<StoryOptions> personality = RepeatedMessage.newEmptyInstance(StoryOptions.getFactory());

    private StorySettle() {
    }

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

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

    /**
     * <code>optional uint32 Idx = 1;</code>
     * @return this
     */
    public StorySettle clearIdx() {
      bitField0_ &= ~0x00000001;
      idx = 0;
      return this;
    }

    /**
     * <code>optional uint32 Idx = 1;</code>
     * @return the idx
     */
    public int getIdx() {
      return idx;
    }

    /**
     * <code>optional uint32 Idx = 1;</code>
     * @param value the idx to set
     * @return this
     */
    public StorySettle setIdx(final int value) {
      bitField0_ |= 0x00000001;
      idx = 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 StorySettle 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 StorySettle 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 StorySettle 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 StorySettle setNextPackage(final byte... values) {
      bitField0_ |= 0x00000002;
      nextPackage.copyFrom(values);
      return this;
    }

    /**
     * <code>repeated .StoryOptions Major = 2;</code>
     * @return whether the major field is set
     */
    public boolean hasMajor() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated .StoryOptions Major = 2;</code>
     * @return this
     */
    public StorySettle clearMajor() {
      bitField0_ &= ~0x00000004;
      major.clear();
      return this;
    }

    /**
     * <code>repeated .StoryOptions Major = 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 #getMutableMajor()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<StoryOptions> getMajor() {
      return major;
    }

    /**
     * <code>repeated .StoryOptions Major = 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<StoryOptions> getMutableMajor() {
      bitField0_ |= 0x00000004;
      return major;
    }

    /**
     * <code>repeated .StoryOptions Major = 2;</code>
     * @param value the major to add
     * @return this
     */
    public StorySettle addMajor(final StoryOptions value) {
      bitField0_ |= 0x00000004;
      major.add(value);
      return this;
    }

    /**
     * <code>repeated .StoryOptions Major = 2;</code>
     * @param values the major to add
     * @return this
     */
    public StorySettle addAllMajor(final StoryOptions... values) {
      bitField0_ |= 0x00000004;
      major.addAll(values);
      return this;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</code>
     * @return whether the personality field is set
     */
    public boolean hasPersonality() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</code>
     * @return this
     */
    public StorySettle clearPersonality() {
      bitField0_ &= ~0x00000008;
      personality.clear();
      return this;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</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 #getMutablePersonality()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<StoryOptions> getPersonality() {
      return personality;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</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<StoryOptions> getMutablePersonality() {
      bitField0_ |= 0x00000008;
      return personality;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</code>
     * @param value the personality to add
     * @return this
     */
    public StorySettle addPersonality(final StoryOptions value) {
      bitField0_ |= 0x00000008;
      personality.add(value);
      return this;
    }

    /**
     * <code>repeated .StoryOptions Personality = 3;</code>
     * @param values the personality to add
     * @return this
     */
    public StorySettle addAllPersonality(final StoryOptions... values) {
      bitField0_ |= 0x00000008;
      personality.addAll(values);
      return this;
    }

    @Override
    public StorySettle copyFrom(final StorySettle other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        idx = other.idx;
        nextPackage.copyFrom(other.nextPackage);
        major.copyFrom(other.major);
        personality.copyFrom(other.personality);
      }
      return this;
    }

    @Override
    public StorySettle mergeFrom(final StorySettle other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasIdx()) {
        setIdx(other.idx);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasMajor()) {
        getMutableMajor().addAll(other.major);
      }
      if (other.hasPersonality()) {
        getMutablePersonality().addAll(other.personality);
      }
      return this;
    }

    @Override
    public StorySettle clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      idx = 0;
      nextPackage.clear();
      major.clear();
      personality.clear();
      return this;
    }

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof StorySettle)) {
        return false;
      }
      StorySettle other = (StorySettle) o;
      return bitField0_ == other.bitField0_
        && (!hasIdx() || idx == other.idx)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasMajor() || major.equals(other.major))
        && (!hasPersonality() || personality.equals(other.personality));
    }

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

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

    @Override
    @SuppressWarnings("fallthrough")
    public StorySettle mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 8: {
            // idx
            idx = input.readUInt32();
            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: {
            // major
            tag = input.readRepeatedMessage(major, tag);
            bitField0_ |= 0x00000004;
            if (tag != 26) {
              break;
            }
          }
          case 26: {
            // personality
            tag = input.readRepeatedMessage(personality, tag);
            bitField0_ |= 0x00000008;
            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.idx, idx);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedMessage(FieldNames.major, major);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedMessage(FieldNames.personality, personality);
      }
      output.endObject();
    }

    @Override
    public StorySettle mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 73373: {
            if (input.isAtField(FieldNames.idx)) {
              if (!input.trySkipNullValue()) {
                idx = 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 74106265: {
            if (input.isAtField(FieldNames.major)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(major);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 1243902542: {
            if (input.isAtField(FieldNames.personality)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(personality);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum StorySettleFactory implements MessageFactory<StorySettle> {
      INSTANCE;

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

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

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

      static final FieldName major = FieldName.forField("Major");

      static final FieldName personality = FieldName.forField("Personality");
    }
  }

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

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

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

    /**
     * <code>repeated uint32 Evidences = 15;</code>
     */
    private final RepeatedInt evidences = RepeatedInt.newEmptyInstance();

    /**
     * <code>repeated .StorySettle List = 1;</code>
     */
    private final RepeatedMessage<StorySettle> list = RepeatedMessage.newEmptyInstance(StorySettle.getFactory());

    private StorySettleReq() {
    }

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

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

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

    /**
     * <code>optional .Events Events = 14;</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 = 14;</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_ |= 0x00000001;
      return events;
    }

    /**
     * <code>optional .Events Events = 14;</code>
     * @param value the events to set
     * @return this
     */
    public StorySettleReq setEvents(final Public.Events value) {
      bitField0_ |= 0x00000001;
      events.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 StorySettleReq 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 StorySettleReq 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 StorySettleReq 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 StorySettleReq setNextPackage(final byte... values) {
      bitField0_ |= 0x00000002;
      nextPackage.copyFrom(values);
      return this;
    }

    /**
     * <code>repeated uint32 Evidences = 15;</code>
     * @return whether the evidences field is set
     */
    public boolean hasEvidences() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>repeated uint32 Evidences = 15;</code>
     * @return this
     */
    public StorySettleReq clearEvidences() {
      bitField0_ &= ~0x00000004;
      evidences.clear();
      return this;
    }

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

    /**
     * <code>repeated uint32 Evidences = 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 RepeatedInt getMutableEvidences() {
      bitField0_ |= 0x00000004;
      return evidences;
    }

    /**
     * <code>repeated uint32 Evidences = 15;</code>
     * @param value the evidences to add
     * @return this
     */
    public StorySettleReq addEvidences(final int value) {
      bitField0_ |= 0x00000004;
      evidences.add(value);
      return this;
    }

    /**
     * <code>repeated uint32 Evidences = 15;</code>
     * @param values the evidences to add
     * @return this
     */
    public StorySettleReq addAllEvidences(final int... values) {
      bitField0_ |= 0x00000004;
      evidences.addAll(values);
      return this;
    }

    /**
     * <code>repeated .StorySettle List = 1;</code>
     * @return whether the list field is set
     */
    public boolean hasList() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>repeated .StorySettle List = 1;</code>
     * @return this
     */
    public StorySettleReq clearList() {
      bitField0_ &= ~0x00000008;
      list.clear();
      return this;
    }

    /**
     * <code>repeated .StorySettle List = 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 #getMutableList()} if you want to modify it.
     *
     * @return internal storage object for reading
     */
    public RepeatedMessage<StorySettle> getList() {
      return list;
    }

    /**
     * <code>repeated .StorySettle List = 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<StorySettle> getMutableList() {
      bitField0_ |= 0x00000008;
      return list;
    }

    /**
     * <code>repeated .StorySettle List = 1;</code>
     * @param value the list to add
     * @return this
     */
    public StorySettleReq addList(final StorySettle value) {
      bitField0_ |= 0x00000008;
      list.add(value);
      return this;
    }

    /**
     * <code>repeated .StorySettle List = 1;</code>
     * @param values the list to add
     * @return this
     */
    public StorySettleReq addAllList(final StorySettle... values) {
      bitField0_ |= 0x00000008;
      list.addAll(values);
      return this;
    }

    @Override
    public StorySettleReq copyFrom(final StorySettleReq other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        events.copyFrom(other.events);
        nextPackage.copyFrom(other.nextPackage);
        evidences.copyFrom(other.evidences);
        list.copyFrom(other.list);
      }
      return this;
    }

    @Override
    public StorySettleReq mergeFrom(final StorySettleReq other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasEvents()) {
        getMutableEvents().mergeFrom(other.events);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      if (other.hasEvidences()) {
        getMutableEvidences().addAll(other.evidences);
      }
      if (other.hasList()) {
        getMutableList().addAll(other.list);
      }
      return this;
    }

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

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

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof StorySettleReq)) {
        return false;
      }
      StorySettleReq other = (StorySettleReq) o;
      return bitField0_ == other.bitField0_
        && (!hasEvents() || events.equals(other.events))
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage))
        && (!hasEvidences() || evidences.equals(other.evidences))
        && (!hasList() || list.equals(other.list));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 114);
        output.writeMessageNoTag(events);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawLittleEndian16((short) 32762);
        output.writeBytesNoTag(nextPackage);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        for (int i = 0; i < evidences.length(); i++) {
          output.writeRawByte((byte) 120);
          output.writeUInt32NoTag(evidences.array()[i]);
        }
      }
      if ((bitField0_ & 0x00000008) != 0) {
        for (int i = 0; i < list.length(); i++) {
          output.writeRawByte((byte) 10);
          output.writeMessageNoTag(list.get(i));
        }
      }
    }

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

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

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeMessage(FieldNames.events, events);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeBytes(FieldNames.nextPackage, nextPackage);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRepeatedUInt32(FieldNames.evidences, evidences);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRepeatedMessage(FieldNames.list, list);
      }
      output.endObject();
    }

    @Override
    public StorySettleReq mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 2087505209: {
            if (input.isAtField(FieldNames.events)) {
              if (!input.trySkipNullValue()) {
                input.readMessage(events);
                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 991055068: {
            if (input.isAtField(FieldNames.evidences)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedUInt32(evidences);
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2368702: {
            if (input.isAtField(FieldNames.list)) {
              if (!input.trySkipNullValue()) {
                input.readRepeatedMessage(list);
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

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

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

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

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

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

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

    private enum StorySettleReqFactory implements MessageFactory<StorySettleReq> {
      INSTANCE;

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

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

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

      static final FieldName evidences = FieldName.forField("Evidences");

      static final FieldName list = FieldName.forField("List");
    }
  }

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

    /**
     * <code>optional uint32 Group = 1;</code>
     */
    private int group;

    /**
     * <code>optional uint32 Choice = 2;</code>
     */
    private int choice;

    /**
     * <code>optional uint32 Factor = 3;</code>
     */
    private int factor;

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

    private StoryOptions() {
    }

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

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

    /**
     * <code>optional uint32 Group = 1;</code>
     * @return this
     */
    public StoryOptions clearGroup() {
      bitField0_ &= ~0x00000001;
      group = 0;
      return this;
    }

    /**
     * <code>optional uint32 Group = 1;</code>
     * @return the group
     */
    public int getGroup() {
      return group;
    }

    /**
     * <code>optional uint32 Group = 1;</code>
     * @param value the group to set
     * @return this
     */
    public StoryOptions setGroup(final int value) {
      bitField0_ |= 0x00000001;
      group = value;
      return this;
    }

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

    /**
     * <code>optional uint32 Choice = 2;</code>
     * @return this
     */
    public StoryOptions clearChoice() {
      bitField0_ &= ~0x00000002;
      choice = 0;
      return this;
    }

    /**
     * <code>optional uint32 Choice = 2;</code>
     * @return the choice
     */
    public int getChoice() {
      return choice;
    }

    /**
     * <code>optional uint32 Choice = 2;</code>
     * @param value the choice to set
     * @return this
     */
    public StoryOptions setChoice(final int value) {
      bitField0_ |= 0x00000002;
      choice = value;
      return this;
    }

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

    /**
     * <code>optional uint32 Factor = 3;</code>
     * @return this
     */
    public StoryOptions clearFactor() {
      bitField0_ &= ~0x00000004;
      factor = 0;
      return this;
    }

    /**
     * <code>optional uint32 Factor = 3;</code>
     * @return the factor
     */
    public int getFactor() {
      return factor;
    }

    /**
     * <code>optional uint32 Factor = 3;</code>
     * @param value the factor to set
     * @return this
     */
    public StoryOptions setFactor(final int value) {
      bitField0_ |= 0x00000004;
      factor = 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 StoryOptions 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 StoryOptions 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 StoryOptions 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 StoryOptions setNextPackage(final byte... values) {
      bitField0_ |= 0x00000008;
      nextPackage.copyFrom(values);
      return this;
    }

    @Override
    public StoryOptions copyFrom(final StoryOptions other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        group = other.group;
        choice = other.choice;
        factor = other.factor;
        nextPackage.copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public StoryOptions mergeFrom(final StoryOptions other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasGroup()) {
        setGroup(other.group);
      }
      if (other.hasChoice()) {
        setChoice(other.choice);
      }
      if (other.hasFactor()) {
        setFactor(other.factor);
      }
      if (other.hasNextPackage()) {
        getMutableNextPackage().copyFrom(other.nextPackage);
      }
      return this;
    }

    @Override
    public StoryOptions clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      group = 0;
      choice = 0;
      factor = 0;
      nextPackage.clear();
      return this;
    }

    @Override
    public StoryOptions 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 StoryOptions)) {
        return false;
      }
      StoryOptions other = (StoryOptions) o;
      return bitField0_ == other.bitField0_
        && (!hasGroup() || group == other.group)
        && (!hasChoice() || choice == other.choice)
        && (!hasFactor() || factor == other.factor)
        && (!hasNextPackage() || nextPackage.equals(other.nextPackage));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 8);
        output.writeUInt32NoTag(group);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(choice);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(factor);
      }
      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(group);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(choice);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(factor);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 2 + ProtoSink.computeBytesSizeNoTag(nextPackage);
      }
      return size;
    }

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

    @Override
    public StoryOptions mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 69076575: {
            if (input.isAtField(FieldNames.group)) {
              if (!input.trySkipNullValue()) {
                group = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2017610177: {
            if (input.isAtField(FieldNames.choice)) {
              if (!input.trySkipNullValue()) {
                choice = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 2096686447: {
            if (input.isAtField(FieldNames.factor)) {
              if (!input.trySkipNullValue()) {
                factor = input.readUInt32();
                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 StoryOptions clone() {
      return new StoryOptions().copyFrom(this);
    }

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

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

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

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

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

    private enum StoryOptionsFactory implements MessageFactory<StoryOptions> {
      INSTANCE;

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

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

      static final FieldName choice = FieldName.forField("Choice");

      static final FieldName factor = FieldName.forField("Factor");

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