I am new to OCL, I am using papyrus on eclipse luna 4.4.2
I have a class diagram named CLIENT with the constraint {all attributes are out of scope} a second class named Customer with the constraint {all attributes are mandatory} and another class call Address having an attribute provenance with the constraint {provenance shall be mandatory}
How should I write the OCL constraint that suit the formal language?
will also like to know how to verify the correctness of the syntax?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In case of an collection it checks for non-emptiness and otherwise for an attribute it checks for non-null.
context Address inv: self.provenance->notEmpty()
For the other classes you have to do this for every attribute. If you want to do this for every attribute with one invariant you have to formulate them on the metamodel.