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

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

      writer.onHeaderWritten();
    }

    switch (writer.state()) {
      case 0:
        if (!writer.writeByteArray("val", val)) 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 3:
        if (!writer.writeMessage("conflictExpireTimes", conflictExpireTimes)) return false;

        writer.incrementState();

      case 4:
        if (!writer.writeMessage("conflictTtls", conflictTtls)) return false;

        writer.incrementState();

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

        writer.incrementState();

      case 6:
        if (!writer.writeCollection(
            "entryProcessorsBytes", entryProcessorsBytes, MessageCollectionItemType.BYTE_ARR))
          return false;

        writer.incrementState();

      case 7:
        if (!writer.writeByteArray("expiryPlcBytes", expiryPlcBytes)) return false;

        writer.incrementState();

      case 8:
        if (!writer.writeBoolean("fastMap", fastMap)) return false;

        writer.incrementState();

      case 9:
        if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG)) return false;

        writer.incrementState();

      case 10:
        if (!writer.writeMessage("futVer", futVer)) return false;

        writer.incrementState();

      case 11:
        if (!writer.writeBoolean("hasPrimary", hasPrimary)) return false;

        writer.incrementState();

      case 12:
        if (!writer.writeObjectArray(
            "invokeArgsBytes", invokeArgsBytes, MessageCollectionItemType.BYTE_ARR)) return false;

        writer.incrementState();

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

        writer.incrementState();

      case 14:
        if (!writer.writeByte("op", op != null ? (byte) op.ordinal() : -1)) return false;

        writer.incrementState();

      case 15:
        if (!writer.writeBoolean("retval", retval)) return false;

        writer.incrementState();

      case 16:
        if (!writer.writeBoolean("skipStore", skipStore)) return false;

        writer.incrementState();

      case 17:
        if (!writer.writeUuid("subjId", subjId)) return false;

        writer.incrementState();

      case 18:
        if (!writer.writeByte("syncMode", syncMode != null ? (byte) syncMode.ordinal() : -1))
          return false;

        writer.incrementState();

      case 19:
        if (!writer.writeInt("taskNameHash", taskNameHash)) return false;

        writer.incrementState();

      case 20:
        if (!writer.writeMessage("topVer", topVer)) return false;

        writer.incrementState();

      case 21:
        if (!writer.writeMessage("updateVer", updateVer)) return false;

        writer.incrementState();

      case 22:
        if (!writer.writeCollection("vals", vals, 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;
  }
  /** {@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 8:
        if (!writer.writeByte(
            "concurrency", concurrency != null ? (byte) concurrency.ordinal() : -1)) return false;

        writer.incrementState();

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

        writer.incrementState();

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

        writer.incrementState();

      case 11:
        if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false;

        writer.incrementState();

      case 12:
        if (!writer.writeBoolean("invalidate", invalidate)) return false;

        writer.incrementState();

      case 13:
        if (!writer.writeByte("isolation", isolation != null ? (byte) isolation.ordinal() : -1))
          return false;

        writer.incrementState();

      case 14:
        if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit)) return false;

        writer.incrementState();

      case 15:
        if (!writer.writeBoolean("partLock", partLock)) return false;

        writer.incrementState();

      case 16:
        if (!writer.writeByte("plc", plc != null ? (byte) plc.ordinal() : -1)) return false;

        writer.incrementState();

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

        writer.incrementState();

      case 18:
        if (!writer.writeBoolean("sys", sys)) return false;

        writer.incrementState();

      case 19:
        if (!writer.writeLong("threadId", threadId)) return false;

        writer.incrementState();

      case 20:
        if (!writer.writeLong("timeout", timeout)) return false;

        writer.incrementState();

      case 21:
        if (!writer.writeByteArray("txNodesBytes", txNodesBytes)) return false;

        writer.incrementState();

      case 22:
        if (!writer.writeInt("txSize", txSize)) return false;

        writer.incrementState();

      case 23:
        if (!writer.writeMessage("writeVer", writeVer)) return false;

        writer.incrementState();

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

        writer.incrementState();
    }

    return true;
  }