Visual OCL

TU-Berlin | Faculty IV | Institute ISTI | Research group TFS

Language elements with examples

small logo
section: < previous | next >
| |
chapter: << previous | next >>

2.3 Navigation along a association class

Constraints with association classes are a consequent extension of standard constraints with simple associations. In case of unlabelled association ends in the class diagram you can use the lower case class name to navigate the required direction.

The example in figure 2.3 describes, that the date of marriage has to be after the date of birth.

Fig. 2.3 A navigation along an association class

The corresponding OCL text is:
context Person inv: self.birthDate < self.marriage.date

2.4 Navigation starting at a association class

Navigations may also start at association classes. The start-role self will then be an instance of an association class.

The example in figure 2.4 describes, that each job has to be assigned to a person, who is working on it.

Fig. 2.4 A navigation starting at an association class

The corresponding OCL text is:
context Job inv: self.employer.numberOfEmployees >= 1


  section: < previous | next >
| |
chapter: << previous | next >>
©2005 TFS