Type checking


expression instanceof typeName



The instanceof function 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.

For metatypes, you can perform a strict type checking using the eClass().name method.


// Returns true if myClass is an instance of Class, or one of its subtypes (e.g. AssociationClass)
myClass instanceof uml21.Class

// Returns true if and only if myClass is a Class, not one of its subtypes (e.g. not a AssociationClass)
myClass.eClass().name == "Class"

// Returns true if thisObject is an instance of a List
thisObject instanceof java.util.List