How to write OCL contraint

允我心安 提交于 2019-12-25 16:24:59

问题


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.



来源:https://stackoverflow.com/questions/32021672/how-to-write-ocl-contraint

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!