OCL - 迭代每个项目
我有一个 A 类和其他类 (B) 的集合。
如何在 OCL 中表示集合中的每个类 (B) 都对某个字段存在约束?
我想是这样的:
A.collection->iterate().field = SomeConstraint
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的术语有点令人困惑。你的意思是你有类似的东西
您期望
SomeConstraint
是什么?我猜您正在 OCL 中寻找 A 类所谓的不变量:
更新:
如果你想计数,最简单的方法不是
迭代
,而是执行select(...)->count()
。也许这可以简化你的问题。Your terminology is a bit confusing. Do you mean you have something like
What do you expect
SomeConstraint
to 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.