我正在開發一個使用OCLinEcore編輯器在OCL中定義的一些不變量的Ecore模型。在我的模型中,一些元素引用了EClassifier;在一些OCL約束中,我需要檢查引用的EClassifier是EDataType還是EClass。這裏,在OCLinEcore,模型類似於一個我:使用Ecore分類器的OCL約束 - 未知類型異常
import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';
package Foo : foo = 'some_namespace'
{
class EndPoint
{
attribute name : String[1];
property type : ecore::EClassifier[1];
}
class Coupling
{
invariant Compatibility:
(destination.type.oclIsKindOf(ecore::EDataType) and source.type = destination.type) or
let destinationClass : ecore::EClass = destination.type.oclAsType(ecore::EClass) in
destinationClass.isSuperTypeOf(source.type.oclAsType(ecore::EClass));
property source : EndPoint[1];
property destination : EndPoint[1];
}
}
然而,當我嘗試驗證我的模型的動態實例,異常出現以下消息:
而指派以「耦合」的 「兼容性」約束的評估異常發生:UNKNOW類型([E字形芯, EDataType])
當試圖在OCL交互式控制檯的表達,我獲得正確的結果。定義我的不變量時,我做錯了什麼?我如何編寫一個使用Ecore類型的不變量?