/** {@inheritDoc} */
  @Override
  public boolean readFrom(ByteBuffer buf, MessageReader reader) {
    reader.setBuffer(buf);

    if (!reader.beforeMessageRead()) return false;

    if (!super.readFrom(buf, reader)) return false;

    switch (reader.state()) {
      case 3:
        conflictExpireTimes = reader.readMessage("conflictExpireTimes");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 4:
        conflictTtls = reader.readMessage("conflictTtls");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 5:
        conflictVers = reader.readCollection("conflictVers", MessageCollectionItemType.MSG);

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 6:
        entryProcessorsBytes =
            reader.readCollection("entryProcessorsBytes", MessageCollectionItemType.BYTE_ARR);

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 7:
        expiryPlcBytes = reader.readByteArray("expiryPlcBytes");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 8:
        fastMap = reader.readBoolean("fastMap");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 9:
        filter =
            reader.readObjectArray(
                "filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class);

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 10:
        futVer = reader.readMessage("futVer");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 11:
        hasPrimary = reader.readBoolean("hasPrimary");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 12:
        invokeArgsBytes =
            reader.readObjectArray(
                "invokeArgsBytes", MessageCollectionItemType.BYTE_ARR, byte[].class);

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 13:
        keys = reader.readCollection("keys", MessageCollectionItemType.MSG);

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 14:
        byte opOrd;

        opOrd = reader.readByte("op");

        if (!reader.isLastRead()) return false;

        op = GridCacheOperation.fromOrdinal(opOrd);

        reader.incrementState();

      case 15:
        retval = reader.readBoolean("retval");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 16:
        skipStore = reader.readBoolean("skipStore");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 17:
        subjId = reader.readUuid("subjId");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 18:
        byte syncModeOrd;

        syncModeOrd = reader.readByte("syncMode");

        if (!reader.isLastRead()) return false;

        syncMode = CacheWriteSynchronizationMode.fromOrdinal(syncModeOrd);

        reader.incrementState();

      case 19:
        taskNameHash = reader.readInt("taskNameHash");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 20:
        topVer = reader.readMessage("topVer");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 21:
        updateVer = reader.readMessage("updateVer");

        if (!reader.isLastRead()) return false;

        reader.incrementState();

      case 22:
        vals = reader.readCollection("vals", MessageCollectionItemType.MSG);

        if (!reader.isLastRead()) return false;

        reader.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;
  }