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 @@ -17,8 +17,8 @@

import io.serverlessworkflow.api.types.func.CallJava;
import io.serverlessworkflow.api.types.func.CallTaskJava;
import io.serverlessworkflow.api.types.func.JavaContextFunction;
import io.serverlessworkflow.api.types.func.JavaFilterFunction;
import io.serverlessworkflow.api.types.func.ContextFunction;
import io.serverlessworkflow.api.types.func.FilterFunction;
import io.serverlessworkflow.fluent.func.spi.ConditionalTaskBuilder;
import io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations;
import io.serverlessworkflow.fluent.spec.TaskBaseBuilder;
Expand Down Expand Up @@ -51,22 +51,21 @@ public <T, V> FuncCallTaskBuilder function(Function<T, V> function, Class<T> arg
return this;
}

public <T, V> FuncCallTaskBuilder function(JavaContextFunction<T, V> function) {
public <T, V> FuncCallTaskBuilder function(ContextFunction<T, V> function) {
return function(function, null);
}

public <T, V> FuncCallTaskBuilder function(
JavaContextFunction<T, V> function, Class<T> argClass) {
public <T, V> FuncCallTaskBuilder function(ContextFunction<T, V> function, Class<T> argClass) {
this.callTaskJava = new CallTaskJava(CallJava.function(function, argClass));
super.setTask(this.callTaskJava.getCallJava());
return this;
}

public <T, V> FuncCallTaskBuilder function(JavaFilterFunction<T, V> function) {
public <T, V> FuncCallTaskBuilder function(FilterFunction<T, V> function) {
return function(function, null);
}

public <T, V> FuncCallTaskBuilder function(JavaFilterFunction<T, V> function, Class<T> argClass) {
public <T, V> FuncCallTaskBuilder function(FilterFunction<T, V> function, Class<T> argClass) {
this.callTaskJava = new CallTaskJava(CallJava.function(function, argClass));
super.setTask(this.callTaskJava.getCallJava());
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.serverlessworkflow.api.types.SwitchCase;
import io.serverlessworkflow.api.types.SwitchItem;
import io.serverlessworkflow.api.types.SwitchTask;
import io.serverlessworkflow.api.types.func.SwitchCaseFunction;
import io.serverlessworkflow.api.types.func.SwitchCasePredicate;
import io.serverlessworkflow.fluent.func.spi.ConditionalTaskBuilder;
import io.serverlessworkflow.fluent.func.spi.FuncTaskTransformations;
import io.serverlessworkflow.fluent.spec.TaskBaseBuilder;
Expand Down Expand Up @@ -59,7 +59,7 @@ public FuncSwitchTaskBuilder onPredicate(
String name, Consumer<SwitchCasePredicateBuilder> consumer) {
final SwitchCasePredicateBuilder switchCase = new SwitchCasePredicateBuilder();
consumer.accept(switchCase);
final SwitchCaseFunction switchCaseValue = (SwitchCaseFunction) switchCase.build();
final SwitchCasePredicate switchCaseValue = (SwitchCasePredicate) switchCase.build();

// Handling default cases
if (switchCaseValue.predicate() == null) {
Expand Down Expand Up @@ -89,10 +89,10 @@ public SwitchTask build() {
}

public static final class SwitchCasePredicateBuilder {
private final SwitchCaseFunction switchCase;
private final SwitchCasePredicate switchCase;

SwitchCasePredicateBuilder() {
this.switchCase = new SwitchCaseFunction();
this.switchCase = new SwitchCasePredicate();
}

public <T> SwitchCasePredicateBuilder when(Predicate<T> when) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package io.serverlessworkflow.fluent.func.dsl;

import io.serverlessworkflow.api.types.func.JavaContextFunction;
import io.serverlessworkflow.api.types.func.JavaFilterFunction;
import io.serverlessworkflow.api.types.func.ContextFunction;
import io.serverlessworkflow.api.types.func.FilterFunction;
import io.serverlessworkflow.fluent.func.FuncCallTaskBuilder;
import io.serverlessworkflow.fluent.func.FuncTaskItemListBuilder;
import java.util.function.Consumer;
Expand All @@ -26,8 +26,8 @@ public final class FuncCallStep<T, R> extends Step<FuncCallStep<T, R>, FuncCallT

private final String name;
private final Function<T, R> fn;
private final JavaContextFunction<T, R> ctxFn;
private final JavaFilterFunction<T, R> filterFn;
private final ContextFunction<T, R> ctxFn;
private final FilterFunction<T, R> filterFn;
private final Class<T> argClass;

/** Function<T,R> variant (unnamed). */
Expand All @@ -45,12 +45,12 @@ public final class FuncCallStep<T, R> extends Step<FuncCallStep<T, R>, FuncCallT
}

/** JavaContextFunction<T,R> variant (unnamed). */
FuncCallStep(JavaContextFunction<T, R> ctxFn, Class<T> argClass) {
FuncCallStep(ContextFunction<T, R> ctxFn, Class<T> argClass) {
this(null, ctxFn, argClass);
}

/** JavaContextFunction<T,R> variant (named). */
FuncCallStep(String name, JavaContextFunction<T, R> ctxFn, Class<T> argClass) {
FuncCallStep(String name, ContextFunction<T, R> ctxFn, Class<T> argClass) {
this.name = name;
this.fn = null;
this.ctxFn = ctxFn;
Expand All @@ -59,12 +59,12 @@ public final class FuncCallStep<T, R> extends Step<FuncCallStep<T, R>, FuncCallT
}

/** JavaFilterFunction<T,R> variant (unnamed). */
FuncCallStep(JavaFilterFunction<T, R> filterFn, Class<T> argClass) {
FuncCallStep(FilterFunction<T, R> filterFn, Class<T> argClass) {
this(null, filterFn, argClass);
}

/** JavaFilterFunction<T,R> variant (named). */
FuncCallStep(String name, JavaFilterFunction<T, R> filterFn, Class<T> argClass) {
FuncCallStep(String name, FilterFunction<T, R> filterFn, Class<T> argClass) {
Comment on lines 47 to +67
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The constructor/variant comments still refer to JavaContextFunction / JavaFilterFunction, but the types were renamed to ContextFunction / FilterFunction. Updating these comments will keep the DSL docs aligned with the public API names.

Copilot uses AI. Check for mistakes.
this.name = name;
this.fn = null;
this.ctxFn = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import io.cloudevents.CloudEventData;
import io.serverlessworkflow.api.types.FlowDirectiveEnum;
import io.serverlessworkflow.api.types.func.JavaContextFunction;
import io.serverlessworkflow.api.types.func.JavaFilterFunction;
import io.serverlessworkflow.api.types.func.ContextFunction;
import io.serverlessworkflow.api.types.func.FilterFunction;
import io.serverlessworkflow.fluent.func.FuncCallTaskBuilder;
import io.serverlessworkflow.fluent.func.FuncEmitTaskBuilder;
import io.serverlessworkflow.fluent.func.FuncSwitchTaskBuilder;
Expand Down Expand Up @@ -281,7 +281,7 @@ public static FuncPredicateEventConfigurer event(String type) {

/**
* Build a call step for functions that need {@link WorkflowContextData} as the first parameter.
* The DSL wraps it as a {@link JavaContextFunction} and injects the runtime context.
* The DSL wraps it as a {@link ContextFunction} and injects the runtime context.
*
* <p>Signature expected: {@code (ctx, payload) -> result}
*
Expand All @@ -291,16 +291,16 @@ public static FuncPredicateEventConfigurer event(String type) {
* @param <R> result type
* @return a call step
*/
public static <T, R> FuncCallStep<T, R> withContext(JavaContextFunction<T, R> fn, Class<T> in) {
public static <T, R> FuncCallStep<T, R> withContext(ContextFunction<T, R> fn, Class<T> in) {
return withContext(null, fn, in);
}

public static <T, R> FuncCallStep<T, R> withContext(JavaContextFunction<T, R> fn) {
public static <T, R> FuncCallStep<T, R> withContext(ContextFunction<T, R> fn) {
return withContext(null, fn, ReflectionUtils.inferInputType(fn));
}

/**
* Named variant of {@link #withContext(JavaContextFunction, Class)}.
* Named variant of {@link #withContext(ContextFunction, Class)}.
*
* @param name task name
* @param fn context-aware function
Expand All @@ -310,18 +310,18 @@ public static <T, R> FuncCallStep<T, R> withContext(JavaContextFunction<T, R> fn
* @return a named call step
*/
public static <T, R> FuncCallStep<T, R> withContext(
String name, JavaContextFunction<T, R> fn, Class<T> in) {
String name, ContextFunction<T, R> fn, Class<T> in) {
return new FuncCallStep<>(name, fn, in);
}

public static <T, R> FuncCallStep<T, R> withContext(String name, JavaContextFunction<T, R> fn) {
public static <T, R> FuncCallStep<T, R> withContext(String name, ContextFunction<T, R> fn) {
return new FuncCallStep<>(name, fn, ReflectionUtils.inferInputType(fn));
}

/**
* Build a call step for functions that need {@link WorkflowContextData} and {@link
* TaskContextData} as the first and second parameter. The DSL wraps it as a {@link
* JavaFilterFunction} and injects the runtime context.
* FilterFunction} and injects the runtime context.
*
* <p>Signature expected: {@code (payload, wctx, tctx) -> result}
*
Expand All @@ -331,12 +331,12 @@ public static <T, R> FuncCallStep<T, R> withContext(String name, JavaContextFunc
* @param <R> result type
* @return a call step
*/
public static <T, R> FuncCallStep<T, R> withFilter(JavaFilterFunction<T, R> fn, Class<T> in) {
public static <T, R> FuncCallStep<T, R> withFilter(FilterFunction<T, R> fn, Class<T> in) {
return withFilter(null, fn, in);
}

/**
* Named variant of {@link #withFilter(JavaFilterFunction, Class)}.
* Named variant of {@link #withFilter(FilterFunction, Class)}.
*
* @param name task name
* @param fn context-aware filter function
Expand All @@ -346,15 +346,15 @@ public static <T, R> FuncCallStep<T, R> withFilter(JavaFilterFunction<T, R> fn,
* @return a named call step
*/
public static <T, R> FuncCallStep<T, R> withFilter(
String name, JavaFilterFunction<T, R> fn, Class<T> in) {
String name, FilterFunction<T, R> fn, Class<T> in) {
return new FuncCallStep<>(name, fn, in);
}

public static <T, R> FuncCallStep<T, R> withFilter(JavaFilterFunction<T, R> fn) {
public static <T, R> FuncCallStep<T, R> withFilter(FilterFunction<T, R> fn) {
return withFilter(null, fn, ReflectionUtils.inferInputType(fn));
}

public static <T, R> FuncCallStep<T, R> withFilter(String name, JavaFilterFunction<T, R> fn) {
public static <T, R> FuncCallStep<T, R> withFilter(String name, FilterFunction<T, R> fn) {
return withFilter(name, fn, ReflectionUtils.inferInputType(fn));
}

Expand All @@ -370,7 +370,7 @@ public static <T, R> FuncCallStep<T, R> withFilter(String name, JavaFilterFuncti
*/
public static <T, R> FuncCallStep<T, R> withInstanceId(
String name, InstanceIdFunction<T, R> fn, Class<T> in) {
JavaContextFunction<T, R> jcf = (payload, wctx) -> fn.apply(wctx.instanceData().id(), payload);
ContextFunction<T, R> jcf = (payload, wctx) -> fn.apply(wctx.instanceData().id(), payload);
return new FuncCallStep<>(name, jcf, in);
}

Expand Down Expand Up @@ -426,7 +426,7 @@ static String defaultUniqueId(WorkflowContextData wctx, TaskContextData tctx) {
*/
public static <T, R> FuncCallStep<T, R> withUniqueId(
String name, UniqueIdBiFunction<T, R> fn, Class<T> in) {
JavaFilterFunction<T, R> jff =
FilterFunction<T, R> jff =
(payload, wctx, tctx) -> fn.apply(defaultUniqueId(wctx, tctx), payload);
return new FuncCallStep<>(name, jff, in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package io.serverlessworkflow.fluent.func.dsl;

import io.serverlessworkflow.api.types.func.JavaContextFunction;
import io.serverlessworkflow.api.types.func.JavaFilterFunction;
import io.serverlessworkflow.api.types.func.ContextFunction;
import io.serverlessworkflow.api.types.func.FilterFunction;
import java.lang.invoke.MethodType;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
Expand All @@ -32,12 +32,12 @@ final class ReflectionUtils {
private ReflectionUtils() {}

@SuppressWarnings("unchecked")
static <T> Class<T> inferInputType(JavaContextFunction<T, ?> fn) {
static <T> Class<T> inferInputType(ContextFunction<T, ?> fn) {
return throwIllegalStateIfNull((Class<T>) inferInputTypeFromAny(fn, 0));
}

@SuppressWarnings("unchecked")
static <T> Class<T> inferInputType(JavaFilterFunction<T, ?> fn) {
static <T> Class<T> inferInputType(FilterFunction<T, ?> fn) {
return throwIllegalStateIfNull((Class<T>) inferInputTypeFromAny(fn, 0));
}

Expand Down
Loading
Loading