A model element is represented by the interface MDWObject
,
which is the root interface of metatypes.
When you define a script, the self variable is always available, whatever the implementation language is. This variable is the instance the script is evaluated on (instance of the script's metatype).
MDWObject
provides services to call scripts on model elements:
toObject(String)
:
invokes the specified script (which expects no argument) or metamodel feature.toObject(String, List)
:
invokes the specified script with some arguments.Additional script call methods are provided to convert the evaluation result to a specific type.
Here are the most commonly used:
toString
:
invokes the specified script and returns a String
representation of the evaluation result.
toList
:
invokes the specified script and returns a MDWList
representation of the evaluation result.
toBoolean
:
invokes the specified script and returns a boolean
representation of the evaluation result.
The eIsInstanceOf
method determines if an object is an instance of the given type (or subclass of the type).
This is the strict equivalent of the Java instanceof
operator.
You can get the metatype's name of a model element using the EMF
eClass().getName()
methods.
Each model element can access it model using the
eModel()
method.