/** {@inheritDoc} */
  @Override
  public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
    writer.setBuffer(buf);

    if (!super.writeTo(buf, writer)) return false;

    if (!writer.isHeaderWritten()) {
      if (!writer.writeHeader(directType(), fieldsCount())) return false;

      writer.onHeaderWritten();
    }

    switch (writer.state()) {
      case 0:
        if (!writer.writeIgniteUuid("fileId", fileId)) return false;

        writer.incrementState();

      case 1:
        if (!writer.writeCollection(
            "fragmentRanges", fragmentRanges, MessageCollectionItemType.MSG)) return false;

        writer.incrementState();
    }

    return true;
  }
  /** {@inheritDoc} */
  @Override
  public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
    writer.setBuffer(buf);

    if (!super.writeTo(buf, writer)) return false;

    if (!writer.isHeaderWritten()) {
      if (!writer.writeHeader(directType(), fieldsCount())) return false;

      writer.onHeaderWritten();
    }

    switch (writer.state()) {
      case 10:
        if (!writer.writeMessage("dhtVer", dhtVer)) return false;

        writer.incrementState();

      case 11:
        if (!writer.writeCollection(
            "filterFailedKeys", filterFailedKeys, MessageCollectionItemType.MSG)) return false;

        writer.incrementState();

      case 12:
        if (!writer.writeIgniteUuid("futId", futId)) return false;

        writer.incrementState();

      case 13:
        if (!writer.writeCollection("invalidParts", invalidParts, MessageCollectionItemType.INT))
          return false;

        writer.incrementState();

      case 14:
        if (!writer.writeIgniteUuid("miniId", miniId)) return false;

        writer.incrementState();

      case 15:
        if (!writer.writeCollection("ownedValKeys", ownedValKeys, MessageCollectionItemType.MSG))
          return false;

        writer.incrementState();

      case 16:
        if (!writer.writeCollection("ownedValVals", ownedValVals, MessageCollectionItemType.MSG))
          return false;

        writer.incrementState();

      case 17:
        if (!writer.writeCollection("pending", pending, MessageCollectionItemType.MSG))
          return false;

        writer.incrementState();

      case 18:
        if (!writer.writeMessage("retVal", retVal)) return false;

        writer.incrementState();
    }

    return true;
  }