Document toolboxDocument toolbox

Switch

Description

The Switch unit is a Processor type unit.

A variation of the Filter unit, this unit can be configured to include as many output ports as required. Each output port defined will have an associated predicate or condition to be met. These conditions and their corresponding output port are called cases. Names must be unique, including standard ports (default, error). 

An event enters through the in port. The various predicates are evaluated sequentially, until reaching one that returns a true result. Then, the event is output via the out port associated with the predicate.

If no predicate is met, the event is sent to the default port.

If there are errors produced during the evaluation, these events are enriched with two additional fields, error and exception, and the event is output through the error port.

Configuration

After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:

TabField
Description
GeneralName
Enter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.
Language
Specify the language you will use to write the expression, e.g. Javascript, Groovy, etc.
CasesCases

User-defined cases. Each one defines a condition (when) and a destination (to). All mentioned destinations correspond to newly-created output ports.

Click the plus icon to open the list.

WhenEnter the predicate (condition) to be evaluated using the language specified.
ToEnter a unique name for the output port for events satisfying the predicate. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.

Input ports

PortDescription
inAll events enter through this port.

Output ports

PortDescription
User-definedOutput ports configured with their associated predicates.
defaultOutputs events that evaluated as "false". i.e. do not meet case conditions.
errorOutputs all events that produced an error during evaluation. These events have two additional fields, error, and exception, that describe the error.