Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ protected SELF self() {
// ---------------------------------------------------------------------------

/** Queue a {@code when(predicate)} to be applied on the concrete builder. */
public SELF when(Predicate<?> predicate) {
postConfigurers.add(b -> ((ConditionalTaskBuilder<?>) b).when(predicate));
public <T> SELF when(SerializablePredicate<T> predicate) {
postConfigurers.add(
b ->
((ConditionalTaskBuilder<?>) b)
.when(predicate, ReflectionUtils.inferInputType(predicate)));
return self();
}

Expand Down Expand Up @@ -115,13 +118,16 @@ public SELF then(FlowDirectiveEnum directive) {
* }</pre>
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the transformation function
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(Function)
*/
public <T, V> SELF exportAs(Function<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function));
public <T, R> SELF exportAs(SerializableFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.exportAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -132,13 +138,13 @@ public <T, V> SELF exportAs(Function<T, V> function) {
* <p>This variant allows you to explicitly specify the input type class for better type safety.
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the transformation function
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(Function, Class)
*/
public <T, V> SELF exportAs(Function<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF exportAs(Function<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function, taskResultClass));
return self();
}
Expand All @@ -150,13 +156,16 @@ public <T, V> SELF exportAs(Function<T, V> function, Class<T> taskResultClass) {
* metadata when shaping the export.
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the filter function with workflow and task context
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(JavaFilterFunction)
*/
public <T, V> SELF exportAs(JavaFilterFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function));
public <T, R> SELF exportAs(JavaFilterFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.exportAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -165,14 +174,14 @@ public <T, V> SELF exportAs(JavaFilterFunction<T, V> function) {
* with explicit input type.
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the filter function with workflow and task context
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(JavaFilterFunction,
* Class)
*/
public <T, V> SELF exportAs(JavaFilterFunction<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF exportAs(JavaFilterFunction<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function, taskResultClass));
return self();
}
Expand All @@ -184,14 +193,17 @@ public <T, V> SELF exportAs(JavaFilterFunction<T, V> function, Class<T> taskResu
* when shaping the export.
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the context function with workflow context
* @return this step for method chaining
* @see
* io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(JavaContextFunction)
*/
public <T, V> SELF exportAs(JavaContextFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function));
public <T, R> SELF exportAs(JavaContextFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.exportAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -200,15 +212,15 @@ public <T, V> SELF exportAs(JavaContextFunction<T, V> function) {
* explicit input type.
*
* @param <T> the task result type
* @param <V> the export type (what gets forwarded to the next step)
* @param <R> the export type (what gets forwarded to the next step)
* @param function the context function with workflow context
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see
* io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations#exportAs(JavaContextFunction,
* Class)
*/
public <T, V> SELF exportAs(JavaContextFunction<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF exportAs(JavaContextFunction<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).exportAs(function, taskResultClass));
return self();
}
Expand Down Expand Up @@ -255,13 +267,16 @@ public SELF exportAs(String jqExpression) {
* }</pre>
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <R> the output type (what gets written to workflow data)
* @param function the transformation function
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(Function)
*/
public <T, V> SELF outputAs(Function<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function));
public <T, R> SELF outputAs(SerializableFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.outputAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -272,13 +287,13 @@ public <T, V> SELF outputAs(Function<T, V> function) {
* <p>This variant allows you to explicitly specify the input type class for better type safety.
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <R> the output type (what gets written to workflow data)
* @param function the transformation function
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(Function, Class)
*/
public <T, V> SELF outputAs(Function<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF outputAs(Function<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function, taskResultClass));
return self();
}
Expand Down Expand Up @@ -308,29 +323,32 @@ public <T, V> SELF outputAs(Function<T, V> function, Class<T> taskResultClass) {
* }</pre>
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <R> the output type (what gets written to workflow data)
* @param function the filter function with workflow and task context
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(JavaFilterFunction)
*/
public <T, V> SELF outputAs(JavaFilterFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function));
public <T, R> SELF outputAs(JavaFilterFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.outputAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

/**
* Shapes what gets written back into the workflow data document using a context-aware filter
* function with explicit input type.
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <T> the task result typeßßß
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are stray characters in this Javadoc type parameter description (ßßß). This will show up in generated docs and should be removed.

Suggested change
* @param <T> the task result typeßßß
* @param <T> the task result type

Copilot uses AI. Check for mistakes.
* @param <R> the output type (what gets written to workflow data)
* @param function the filter function with workflow and task context
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(JavaFilterFunction,
* Class)
*/
public <T, V> SELF outputAs(JavaFilterFunction<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF outputAs(JavaFilterFunction<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function, taskResultClass));
return self();
}
Expand All @@ -342,13 +360,16 @@ public <T, V> SELF outputAs(JavaFilterFunction<T, V> function, Class<T> taskResu
* when shaping the committed output.
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <R> the output type (what gets written to workflow data)
* @param function the context function with workflow context
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(JavaContextFunction)
*/
public <T, V> SELF outputAs(JavaContextFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function));
public <T, R> SELF outputAs(JavaContextFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.outputAs(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -357,14 +378,14 @@ public <T, V> SELF outputAs(JavaContextFunction<T, V> function) {
* with explicit input type.
*
* @param <T> the task result type
* @param <V> the output type (what gets written to workflow data)
* @param <R> the output type (what gets written to workflow data)
* @param function the context function with workflow context
* @param taskResultClass the class of the task result type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#outputAs(JavaContextFunction,
* Class)
*/
public <T, V> SELF outputAs(JavaContextFunction<T, V> function, Class<T> taskResultClass) {
public <T, R> SELF outputAs(JavaContextFunction<T, R> function, Class<T> taskResultClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).outputAs(function, taskResultClass));
return self();
}
Expand Down Expand Up @@ -410,13 +431,16 @@ public SELF outputAs(String jqExpression) {
* }</pre>
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the transformation function
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(Function)
*/
public <T, V> SELF inputFrom(Function<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function));
public <T, R> SELF inputFrom(SerializableFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.inputFrom(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -434,13 +458,13 @@ public <T, V> SELF inputFrom(Function<T, V> function) {
* }</pre>
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the transformation function
* @param inputClass the class of the input type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(Function, Class)
*/
public <T, V> SELF inputFrom(Function<T, V> function, Class<T> inputClass) {
public <T, R> SELF inputFrom(Function<T, R> function, Class<T> inputClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function, inputClass));
return self();
}
Expand All @@ -466,13 +490,16 @@ public <T, V> SELF inputFrom(Function<T, V> function, Class<T> inputClass) {
* }</pre>
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the filter function with workflow and task context
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(JavaFilterFunction)
*/
public <T, V> SELF inputFrom(JavaFilterFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function));
public <T, R> SELF inputFrom(JavaFilterFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.inputFrom(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -483,14 +510,14 @@ public <T, V> SELF inputFrom(JavaFilterFunction<T, V> function) {
* type specification.
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the filter function with workflow and task context
* @param inputClass the class of the input type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(JavaFilterFunction,
* Class)
*/
public <T, V> SELF inputFrom(JavaFilterFunction<T, V> function, Class<T> inputClass) {
public <T, R> SELF inputFrom(JavaFilterFunction<T, R> function, Class<T> inputClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function, inputClass));
return self();
}
Expand All @@ -502,13 +529,16 @@ public <T, V> SELF inputFrom(JavaFilterFunction<T, V> function, Class<T> inputCl
* you to inspect workflow metadata and current data.
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the context function with workflow context
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(JavaContextFunction)
*/
public <T, V> SELF inputFrom(JavaContextFunction<T, V> function) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function));
public <T, R> SELF inputFrom(JavaContextFunction<T, R> function) {
postConfigurers.add(
b ->
((FuncTaskTransformations<?>) b)
.inputFrom(function, ReflectionUtils.inferInputType(function)));
return self();
}

Expand All @@ -519,14 +549,14 @@ public <T, V> SELF inputFrom(JavaContextFunction<T, V> function) {
* type specification.
*
* @param <T> the input type (workflow data or task input)
* @param <V> the result type (what the task will see as input)
* @param <R> the result type (what the task will see as input)
* @param function the context function with workflow context
* @param inputClass the class of the input type
* @return this step for method chaining
* @see io.serverlessworkflow.fluent.func.spi.FuncTransformations#inputFrom(JavaContextFunction,
* Class)
*/
public <T, V> SELF inputFrom(JavaContextFunction<T, V> function, Class<T> inputClass) {
public <T, R> SELF inputFrom(JavaContextFunction<T, R> function, Class<T> inputClass) {
postConfigurers.add(b -> ((FuncTaskTransformations<?>) b).inputFrom(function, inputClass));
return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

import io.serverlessworkflow.api.types.Workflow;
import io.serverlessworkflow.fluent.func.FuncWorkflowBuilder;
import io.serverlessworkflow.impl.TaskContextData;
import io.serverlessworkflow.impl.WorkflowApplication;
import io.serverlessworkflow.impl.WorkflowContextData;
import io.serverlessworkflow.impl.WorkflowDefinition;
import io.serverlessworkflow.impl.WorkflowModel;
import org.assertj.core.api.SoftAssertions;
Expand All @@ -42,17 +44,15 @@ void test_input_with_inputFrom() {
(Long input) -> {
softly.assertThat(input).isEqualTo(10L);
return input + 5;
},
Long.class),
}),
function("returnEnriched", (Long enrichedValue) -> enrichedValue, Long.class)
.inputFrom(
(object, workflowContext) -> {
(Long object, WorkflowContextData workflowContext) -> {
softly.assertThat(object).isEqualTo(15L);
Long input = input(workflowContext, Long.class);
softly.assertThat(input).isEqualTo(10L);
return object + input;
},
Long.class))
}))
.build();

try (WorkflowApplication app = WorkflowApplication.builder().build()) {
Expand Down Expand Up @@ -118,12 +118,13 @@ void test_output_with_exportAs() {
},
Long.class)
.exportAs(
(object, workflowContext, taskContextData) -> {
(Long object,
WorkflowContextData workflowContext,
TaskContextData taskContextData) -> {
Long taskOutput = output(taskContextData, Long.class);
softly.assertThat(taskOutput).isEqualTo(15L);
return taskOutput * 2;
},
Object.class))
}))
.build();

try (WorkflowApplication app = WorkflowApplication.builder().build()) {
Expand Down