You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Activity diagrams can also implement logic that is based on conditions. You can branch a control flow using the Decision element.

The following example shows an activity diagram that checks if a related REST service is up and running, or not.

The diagram performs a GET request on the service. Directly after this request, any thrown errors are caught and used to identify the status of the service.

The branching conditions must evaluate to a Boolean value (boolean expression) and be defined on the outgoing control flows of the decision node as a Guard Expression. Page Logical Operators provides a list of all possible logical operators that can be used within a guard expression. You can also use Boolean operators (and, or) as described in Boolean Operators.

In the example above, there are two outgoing control flows:

Nr.Control FlowConditionGuard Expression
1

Decision → setNotAvailable

REST service not availablecatch errorCode = "*" errorType = "*"
2

Decision → setReturn

REST service up and runningelse

The one or more of the control flows contain the actual condition(s) (1). Exactly one control flow must contain an else expression (2): This control flow is followed if all other expressions evaluate to false.

The boolean operators of the xUML Runtime support short-circuiting . This means that the second operand is evaluated only when the result is not fully determined by the first operand.

Adding a Guard Expression

To add a guard expression to a control flow proceed as follows:

Select the control flow you want to add a guard expression to from the activity diagram and open the Attributes panel.

Enter a boolean expression into the field Guard Expression.

  • No labels