如何写OCL约束 [英] How to write OCL contraint

查看:203
本文介绍了如何写OCL约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OCL的新手,我在eclipse luna 4.4.2上使用纸莎草纸
我有一个名为CLIENT的类图,带有约束{所有属性都超出范围}第二个类是Customer,它带有约束{所有属性都是强制性的},另一个类调用具有属性出处且带有约束的地址{出处必须是强制性的}


我应该如何编写适合正式语言的OCL约束?
还想知道如何验证语法的正确性吗?

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?

推荐答案

如果是集合,它将检查

上下文地址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.

这篇关于如何写OCL约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆