🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators superTypes
This page was created by Peter on 2019-12-19. Last edited by Wikiadmin on 2026-07-29.

You can use superTypes in OCL when you need the names of a model class's direct parent types, for example when inspecting or validating inheritance in MDriven Designer.

Syntax

TypeName.superTypes

superTypes is a meta-model operation: apply it to a class name, not to an instance of that class.

Return value

Item Value
Return type Collection(System.String)
Contents The names of the type's direct supertypes (its immediate parent classes).
Scope Direct inheritance level only. Indirect ancestors are not included.

Example

Assume that Mango inherits from Fruit and Fruit inherits from SysSuperClass.

Mango.superTypes

The expression returns:

['Fruit']

Fruit is returned because it is the immediate parent of Mango. SysSuperClass is not returned because it is an indirect ancestor.

Direct parents versus all ancestors

Use superTypes when you need only the first inheritance level. Use allSuperTypes when you need the complete ancestor hierarchy.

Expression Result for Mango Use when you need
Mango.superTypes ['Fruit'] Immediate parent types only
Mango.allSuperTypes ['SysSuperClass', 'Fruit'] Both direct and indirect parent types

Use cases

  • Validate that a class has a required immediate parent.
  • Inspect a model's inheritance structure while developing or troubleshooting model logic.
  • Branch logic based on the direct parent type name, when that is the intended level of the hierarchy.

For runtime checks on an object and its inherited types, use oclIsKindOf instead. superTypes examines type metadata; it does not test an object's runtime type.

See also