Class IfExecutor
java.lang.Object
ai.nervemind.app.executor.IfExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "if" node type - provides conditional branching in
workflows.
Evaluates a condition expression and routes execution to different branches based on the result. Uses Spring Expression Language (SpEL) for condition evaluation with support for template interpolation.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| condition | String | "true" | SpEL expression to evaluate |
Template Variables
Use {{ variableName }} syntax to reference input data:
{{ status }} == 'active'- Simple variable comparison{{ data.count }} > 10- Nested path access{{ items[0].value }}- Array index access
SpEL Expression Examples
{{ price }} > 100 and {{ stock }} > 0- Logical AND{{ status }} == 'active' or {{ status }} == 'pending'- Logical OR#input['response'] != null- Null check with SpEL syntax
Output Data
| Key | Type | Description |
|---|---|---|
| conditionResult | Boolean | The evaluated condition result |
| branch | String | "true" or "false" - indicates which branch to take |
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
IfExecutor
public IfExecutor()Default constructor.
-
-
Method Details
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-