Skip to content

[Fix #1372] conversion to no collection type forWorkflowModelCollection#1373

Merged
fjtirado merged 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_#1372
May 8, 2026
Merged

[Fix #1372] conversion to no collection type forWorkflowModelCollection#1373
fjtirado merged 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_#1372

Conversation

@fjtirado
Copy link
Copy Markdown
Collaborator

@fjtirado fjtirado commented May 8, 2026

Fix #1372

Copilot AI review requested due to automatic review settings May 8, 2026 13:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses #1372 by improving event payload conversion so workflows listening to a single event no longer need an explicit outputAs(Collection -> firstElement) step to access the first item.

Changes:

  • Updated CollectionConversionUtils.as(...) to accept Iterable<?> and added a fallback conversion path that converts the first element to the requested non-collection type.
  • Simplified JacksonModelCollection.as(...) to pass the ArrayNode directly into the conversion utility.
  • Updated the fluent DSL test to remove the now-unnecessary outputAs(...iterator().next()) workaround.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
impl/model/src/main/java/io/serverlessworkflow/impl/model/jackson/JacksonModelCollection.java Routes ArrayNode directly into shared conversion utility to enable single-item conversion.
impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Broadens input to Iterable and adds “convert first element” behavior for non-collection targets.
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/FuncEventFilterTest.java Removes manual “first element” extraction to validate the improved conversion behavior.
Comments suppressed due to low confidence (1)

impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:81

  • The @see #as(Collection, Class, BiFunction) reference no longer matches an existing overload after the signature change (the 3-arg method now takes Iterable). Update the @see target so Javadoc resolves correctly.
  /**
   * @see #as(Collection, Class, BiFunction)
   */
  public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
    return as(elements, clazz, (item, type) -> item);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Outdated
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Outdated
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Outdated
@fjtirado fjtirado requested review from mcruzdev and ricardozanini May 8, 2026 13:23
Copilot AI review requested due to automatic review settings May 8, 2026 13:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:90

  • The @see tag references #as(Collection, Class, BiFunction), but that overload no longer exists (it is now as(Iterable, Class, BiFunction)). Update the @see to point to the correct method signature to avoid broken Javadoc links/doclint failures.
  /**
   * @see #as(Collection, Class, BiFunction)
   */
  public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
    return as(elements, clazz, (item, type) -> item);
  }

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Outdated
@fjtirado fjtirado marked this pull request as draft May 8, 2026 14:15
@fjtirado fjtirado marked this pull request as ready for review May 8, 2026 15:34
Copilot AI review requested due to automatic review settings May 8, 2026 15:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:104

  • The @see tag references #as(Collection, Class, BiFunction), but that overload no longer exists after changing the primary API to as(Iterable, ...). Update the Javadoc reference to the correct method signature to avoid broken documentation links.
  /**
   * @see #as(Collection, Class, BiFunction)
   */
  public static <T> Optional<T> as(Collection<?> elements, Class<T> clazz) {
    return as(elements, clazz, (item, type) -> item);
  }

Comment thread impl/json-utils/src/main/java/io/serverlessworkflow/impl/jackson/JsonUtils.java Outdated
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java Outdated
Copilot AI review requested due to automatic review settings May 8, 2026 15:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

impl/core/src/main/java/io/serverlessworkflow/impl/CollectionConversionUtils.java:104

  • The Javadoc @see tag references #as(Collection, Class, BiFunction), but that overload no longer exists (the 3-arg overload is now as(Iterable, Class, BiFunction)). Update the reference to avoid broken Javadoc links (and potential Javadoc build warnings/failures if doclint is enabled).

Comment thread impl/json-utils/src/main/java/io/serverlessworkflow/impl/jackson/JsonUtils.java Outdated
…kflowModelCollection

Signed-off-by: fjtirado <ftirados@redhat.com>
Copilot AI review requested due to automatic review settings May 8, 2026 15:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@fjtirado fjtirado requested a review from Copilot May 8, 2026 16:27
@fjtirado fjtirado merged commit 883df5b into serverlessworkflow:main May 8, 2026
9 of 11 checks passed
@fjtirado fjtirado review requested due to automatic review settings May 8, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Experimental] Improve conversion functionality for events

3 participants