I have a class A with a collection of other classes (B).
How do I represent in OCL that for each class (B) in the collection there’s a constraint on a field ?
I thought something like:
A.collection->iterate().field = SomeConstraint
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your terminology is a bit confusing. Do you mean you have something like
What do you expect
SomeConstraintto be?I guess you’re looking for so-called invariants in OCL for class A:
Update:
If you want to count, the easiest way is not
iterate, but doingselect(...)->count(). Maybe that simplifies your matter.