section: < previous | next > | | | |
chapter: << previous | next >> |
2.5 Conditions
In VisualOCL Conditions consists of a variable (on the left side) , compare operator (in the middle) and a variable/constant (on the right side). A variable of a condition is either bound on an attribute, value of a collection classifier or a method's returntype. The condition appears at the bottom of a constraint and belongs to it.2.5.1 Create a Condition
A condition in our editor can be created if a variable was defined anywhere in a method, attribute or size/set operation in SetClassifierRoles. It can be created either by clicking the palette entry "condition" or by selecting the entry "Create a Condition". A dialog in which you can do some settings is opened (see Fig. 2.5.1). In the left combo box you find all variables that a defined in the underlying navigation expression and if it is inside a Let-In expression this variable will also appear. The advantage of procedure is that defined variables can belong to a condition only. In the middle combobox you can choose an operator, that are predefined ones.Fig. 2.5.1 - Condition creating dialog
Fig. 2.5.2 - a Condition example with a constant on the right side
The right side is a special one in that kind that you can either put in a constant such as a number or string, or choose another variable. That can you by enable the checkbox as variable and the dialog changes sightly. The textfield changes to a combobox, which you can choose a variable in. The variable there must also be defined and must have the same type as the variable on the right side. The variable's type is displayed below.
In Fig. 2.5.2 there is a ClassifierRole c:Company that has the variables x and y that are bound to the attributes numberOfEmployees and numberOfHeads. Then you can define a condition between these two variables (see Fig. 2.5.3).
Fig. 2.5.3 - Condition creating with a variable on the right side
2.5.2 Delete a Condition
For deleting a condition you have to click on it and delete it via the context menu. It is possible to delete a condition at any time. In opposite to that it is not possible to delete ClassifierRoles that possesses a variable which is used inside a condiion either on the left or the right side. Then a dialog is opened (see Fig. 2.5.4). This should prohibit that a variable used in a condition left unbound.Fig. 2.5.4 - a variable of the deleting ClassifierRoles is bound at a Condition