【问题标题】:Navigating UML associations in OCL在 OCL 中导航 UML 关联
【发布时间】:2012-12-07 12:14:37
【问题描述】:

我正在尝试使用 eclipse OCL 实现在 OCL 中导航 UML 关联。我知道 UML Associations 被视为 Attributes,并且在 Class 上调用的 getAttributes() 函数将返回一个集合,其中包含 Attributes 以及每个 Property 对象的 Association。但是,我需要的不是Property,而是Association 另一端的Class

对于双向Associations,下面的代码可以工作,虽然看起来不是很优雅:

self.getAllAttributes().opposite.class

它不仅不优雅,而且在定向Associations 上也不起作用(那里没有对面的Property)。在 OCL 中导航 Associations 是否有更好的方法?

【问题讨论】:

    标签: eclipse uml ocl eclipse-mdt


    【解决方案1】:

    使用property.type怎么样?

    【讨论】:

    • 你是对的:使用self.getAllAttributes().type.oclAsType(Class) 有效(当然,只要所有属性都是关联的)。非常感谢!
    【解决方案2】:

    您为什么不尝试使用本文中解释的 OCL 控制台

    http://lowcoupling.com/post/47845805110/ocl-and-the-eclipse-ocl-console

    【讨论】:

      猜你喜欢
      • 2016-01-30
      • 2014-07-30
      • 2019-05-12
      • 1970-01-01
      • 2015-07-09
      • 1970-01-01
      • 2011-06-12
      • 2014-10-30
      • 1970-01-01
      相关资源
      最近更新 更多