public Object[] mapCommand(Command command) { checkNotNull(command, "command must not be null"); Object[] args = new Object[tupleKeys.length + 2]; args[0] = command.getCommandTimestamp(); args[1] = command.getAggregateId().getId(); populateArgsFromTuple(command, args); return args; }
/** * Convert the supplied {@link Command} into a {@link CommandJson} object suitable for JSON serialisation. * @param command The {@link Command} to convert. * @param objectMapper The {@link ObjectMapper} to use to convert the {@link Command}'s parameters into JSON nodes. * @return The converted {@link CommandJson}. */ public static CommandJson of(Command command, ObjectMapper objectMapper) { Function<Object, JsonNode> serialiser = objectMapper::valueToTree; return of( command.getAggregateId().getType(), command.getAggregateId().getId(), command.getCommandName().getName(), command.getCommandName().getVersion(), command.getCommandTimestamp().getTimestamp().toEpochMilli(), command.getCommandTimestamp().getStreamId(), command.getProcessingId().map(UUID::toString).orElse(""), command.getParameters().serialise(serialiser) ); }