Creating an OCL Constraint
To create a constraint using the Tool Palette
- In the Diagram View, open a class diagram (or another diagram supporting constraint elements). On the Tool Palette, choose the Constraint button and click the diagram background. The constraint editor appears.
- Type the constraint expression.
- Close the editor.
- In the Tool Palette, click Constraint link and link the constraint node with the respective modeling element in the diagram.
- In the Model View or in the Diagram View, right-click an element for which a constraint should be created.
- Choose Constraints on the context menu.
- In the Add/Remove Constraints dialog box, click Add.
- Enter the constraint:
- In the Name field, enter the constraint name.
- In the Language field, choose
- In the Constraint field, enter the constraint text.
- Add as many constrains as needed.
- Click OK when ready.
- Created constraints will be linked with the selected modeling element.