Decision

Decisions are used to take some input data as arguments and return a result from an enumerated set of outcomes.

Overview

A decision is similar to a function, the main difference is that it returns a result from an enumerated set of outcomes. The arguments to a decision are defined as input data, they have a name and a Java class (or primitive) type.

Decisions can optionally define internal values, which are similar to local variables. They are useful for extracting values from a complex input or deriving values through some function calls in order to keep the decision logic clear and concise.

When defining a decision, the possible outcomes must be listed. The value returned in the decision function must be contained in the outcome set.

A simple example decision is shown below:

example decision

The decision takes a single integer as it’s input data, anInt. The input data anInt is used to derive a boolean value equalsOne which is later used in an if expression in the decision function to determine whether to return WAS_ONE or WAS_NOT_ONE.

Input Data

Input data can refer to Java primitive types and Java classes.

When referring to a Java class, a Java Record Link is automatically generated and imported. The link is required to bridge the Java class with an equivalent Kernel F record, which can be used in expressions.

Values

Multiple internal values can be defined within a decision. Values can reference input data and other values (providing they are defined before them).

Values have a name, type and expression. The expression must produce a result that matches the value’s type.

Outcomes

Typically, at least two outcomes are defined for each decision.

Outcomes have a name and a description.

Function

A function must be defined for the decision. It may reference the input data or values defined in the decision and must return a decision outcome.

Additional Resources