for each loop

ForEach Loop

Version: 17.07

Supported Since: 17.07

What is a ForEach Loop processor?

ForEach loop processor can be used to iterate over the elements of a Java’s Collection or a Map. This processor behaves similar to the Java 8’s forEach with a Consumer in case of a Collection iteration and Java 8’s forEach with a BiConsumer in case of a Map iteration.

In order to use this processing element, you must first select the Flow Control dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Flow Control dependency.

foreach loop ico labled

Out Ports

Loop termination out

Once the conditions are met to terminate the loop, message context will leave the loop through this port

In loop flow port

If the conditions are met to continue looping, message context will be passed through this port. The flow which starts from this port will act similar to the body of a standard for loop.

On Exception

The message context will be sent to this out port if any exception occurred while looping. However, if an exception thrown during the in loop flow, the loop will be terminated and continue through the exception flow of the corresponding element.

Design of the flow should re connect back to the For Loop processor’s In Port in order to maintain the looping functionality.

Parameters

Collection Variable name *

Basic

Variable name of the context scope variable, which holds the java Collection or Map

Collection Type

Basic

Type of the Java collection. It can be one of the following.

Iterating Variable Name

Basic

This variable behaves differently in two cases of Collection types

  • Collection - The in loop flow can access the current element of java collection from this variable

  • Map - The in loop flow can access the key of the current <key,value> pair of java map.

Variable to assign the value corresponding to the key

Basic

This parameter is applicable only in the case of Map. The in loop flow can access the value of the current <key,value> pair of java map from this variable.

In this topic
In this topic
Contact Us