RAD Studio (Common)
ContentsIndex
PreviousUpNext
Creating an OCL Constraint
To create an object constraint and link it with the context:

  1. In the Class/package diagram Tool Palette, choose the Constraint button and click the diagram background. The note element appears with the OCL editor activated.
  2. Type the constraint expression.
  3. Close the OCL editor.
  4. In the diagram Tool Palette, choose the button, and link the constraint node with the respective design element.
    Tip: The constrained attribute should actually exist in the context. Otherwise the constraint will be marked as invalid.

Alternatively, follow these steps:

  1. In the Model View or in the diagram, right-click an element for which a constraint should be created.
  2. Choose Constraints.
  3. In the Add / Remove constraints dialog box, click Add.
  4. Enter the constraint:
    • In the Name field, enter the constraint name.
    • In the Language field, choose OCL or text from the list box.
    • In the Constraint field, enter the constraint text.
  5. Add as many constrains as needed.
  6. Click OK when ready.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!