[Fix #1339] Add SerializableFunction support to ForEach on DSL#1340
Open
fjtirado wants to merge 1 commit intoserverlessworkflow:mainfrom
Open
[Fix #1339] Add SerializableFunction support to ForEach on DSL#1340fjtirado wants to merge 1 commit intoserverlessworkflow:mainfrom
fjtirado wants to merge 1 commit intoserverlessworkflow:mainfrom
Conversation
ricardozanini
approved these changes
Apr 24, 2026
| Function<T, Collection<?>> collection, Consumer<FuncTaskItemListBuilder> body) { | ||
| return list -> list.forEach(j -> j.collection(collection).tasks(body)); | ||
| public static <T, V> FuncTaskConfigurer forEach( | ||
| SerializableFunction<T, Collection<V>> collection, Consumer<FuncTaskItemListBuilder> body) { |
Collaborator
Author
There was a problem hiding this comment.
Dont be hard on you, I also forgot when reviewing (;
fjtirado
commented
Apr 24, 2026
| private Optional<Class<?>> itemClass = Optional.empty(); | ||
| private Optional<Class<?>> forClass = Optional.empty(); | ||
| private Function<?, Collection<?>> collection; | ||
| private Function collection; |
Collaborator
Author
There was a problem hiding this comment.
I sacrifice compile time type checkign here (which was kind of useless anyway) to have compile time type checking in user code.
In particular to verify that the type produce by the collection function matches the type expected by the single function parameter loop funcion.
…Each on DSL Signed-off-by: fjtirado <ftirados@redhat.com>
fjtirado
commented
Apr 24, 2026
Comment on lines
+1031
to
1043
| public static <T, V> FuncTaskConfigurer forEach( | ||
| SerializableFunction<T, Collection<V>> collection, LoopFunction<T, V, ?> function) { | ||
| return list -> | ||
| list.forEach( | ||
| j -> | ||
| j.collection(collection, ReflectionUtils.inferInputType(collection)) | ||
| .tasks(function)); | ||
| } | ||
|
|
||
| public static <T, V> FuncTaskConfigurer forEachItem( | ||
| SerializableFunction<T, Collection<V>> collection, Function<V, ?> function) { | ||
| return forEach(collection, ((t, v) -> function.apply((V) v))); | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Im adding these two ones, which are not directly related with the issue, but I think might be useful to cover most scenarion for users that want to use functions withint the loop (we were already covering the case for other constructs with the existing method)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1339