OCLinEcore エディターを使用して、OCL で定義されたいくつかの不変式を持つ Ecore モデルを開発しています。私のモデルでは、一部の要素が EClassifier への参照を持っています。一部の OCL 制約では、参照されている EClassifier が EDataType か EClass かを確認する必要があります。これは、OCLinEcore にある、私が持っているモデルに似たモデルです。
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];
}
}
ただし、モデルの動的インスタンスを検証しようとすると、次のメッセージで例外が発生します。
'Coupling' の 'Compatibility' 制約の評価を委譲中に例外が発生しました: 不明な型 ([ecore, EDataType])
OCL インタラクティブ コンソールで式を試すと、正しい結果が得られます。不変条件を定義するときに何か間違ったことをしていますか? Ecore 型を使用する不変式を作成するにはどうすればよいですか?