1010import io .temporal .internal .nexus .NexusStartWorkflowHelper ;
1111import io .temporal .workflow .Functions ;
1212import java .util .Objects ;
13- import java .util .function .Consumer ;
1413
1514/**
1615 * Nexus-aware client wrapping {@link WorkflowClient}. Provides methods for interacting with
@@ -73,33 +72,33 @@ public WorkflowClient getWorkflowClient() {
7372 }
7473
7574 /**
76- * Starts a workflow by invoking a method on a workflow stub. The client creates the stub from the
77- * given class and options, then passes it to the provided consumer which should call exactly one
78- * workflow method. Works for both returning and void workflow methods .
75+ * Starts a workflow by invoking a returning method on a workflow stub. The client creates the
76+ * stub from the given class and options, then invokes the workflow method via the provided
77+ * function .
7978 *
80- * <p>Example (returning) :
79+ * <p>Example:
8180 *
8281 * <pre>{@code
8382 * client.startWorkflow(MyWorkflow.class, wf -> wf.run(input), options)
8483 * }</pre>
8584 *
86- * <p>Example ( void) :
85+ * <p>For void-returning workflow methods, use a block lambda that returns null :
8786 *
8887 * <pre>{@code
89- * client.startWorkflow(MyWorkflow.class, wf -> wf.execute(input), options)
88+ * client.startWorkflow(MyWorkflow.class, wf -> { wf.execute(input); return null; } , options)
9089 * }</pre>
9190 *
9291 * @param workflowClass the workflow interface class
93- * @param workflowInvocation receives the workflow stub and calls exactly one workflow method
92+ * @param workflowMethod receives the workflow stub and calls exactly one workflow method
9493 * @param options workflow start options (must include workflowId)
9594 * @param <T> the workflow interface type
96- * @param <R> the workflow return type (inferred from calling context)
95+ * @param <R> the workflow return type
9796 * @return an async {@link TemporalOperationResult} with the workflow-run operation token
9897 */
9998 public <T , R > TemporalOperationResult <R > startWorkflow (
100- Class <T > workflowClass , Consumer < T > workflowInvocation , WorkflowOptions options ) {
99+ Class <T > workflowClass , Functions . Func1 < T , R > workflowMethod , WorkflowOptions options ) {
101100 T stub = client .newWorkflowStub (workflowClass , options );
102- Functions .Proc bound = () -> workflowInvocation . accept (stub );
101+ Functions .Func < R > bound = () -> workflowMethod . apply (stub );
103102 return invokeAndReturn (WorkflowHandle .fromWorkflowMethod (bound ));
104103 }
105104
@@ -120,7 +119,7 @@ public <R> TemporalOperationResult<R> startWorkflow(
120119 return invokeAndReturn (handle );
121120 }
122121
123- private <R > TemporalOperationResult <R > invokeAndReturn (WorkflowHandle <? > handle ) {
122+ private <R > TemporalOperationResult <R > invokeAndReturn (WorkflowHandle <R > handle ) {
124123 NexusStartWorkflowResponse response =
125124 NexusStartWorkflowHelper .startWorkflowAndAttachLinks (
126125 operationContext ,
0 commit comments