toCommandRequest
A request of this command to the aggregate aggregateId names (none for a creation, whose id the server assigns, or a command its body or a transformer addresses), with the fields block sets, by the names of CommandRequest.Builder; toCommandRequest of a ref names the aggregate by its ref instead:
PayOrder(amount).toCommandRequest(orderId)
PayOrder(amount).toCommandRequest(orderId) { wait(WaitPlan.COMMITTED); requestId(paymentId) }
RecordActionRefused(code).toCommandRequest(to = rejected.source)It is the request a saga's handler returns, and the one every entry that takes a command sends (SagaContext.call, SagaContext.schedule, CommandClient.send, CommandClient.wait, CommandClient.stream): context.call(command, id) { ... } is context.call(command.toCommandRequest(id) { ... }). Java builds the same request with CommandRequest.builder.
A request is not a command: one already built is passed as it is, and its fields changed with CommandRequest.toBuilder; making a request of it fails as CommandRequest says.
A request of this command to the aggregate the ref to names, as CommandRequest.to sends (its type, its id when assigned, its tenant), with the fields block sets; see toCommandRequest of an id.