OCLOperators allSuperTypes
This page was created by Alexandra on 2017-08-13. Last edited by Wikiadmin on 2026-07-29.
You can use allSuperTypes in OCL to inspect every inherited type of a class, including both direct and indirect supertypes.
Syntax
TypeName.allSuperTypes
allSuperTypes is a meta-model operation: it examines the type and its inheritance structure. It does not return model objects (instances).
Return value
| Item | Value |
|---|---|
| Return type | Collection(System.String)
|
| Contents | The names of all direct and indirect supertypes of the specified class |
| Order | In inheritance order, starting with the direct supertype and continuing through its ancestors |
Example
Assume that Mango inherits from Fruit, and Fruit inherits from SysSuperClass.
Mango.allSuperTypes
The expression returns:
['Fruit', 'SysSuperClass']
This result lets you inspect the complete ancestry of Mango. For example, you can use it when validating that a class has a required base type somewhere in its inheritance chain.
allSuperTypes compared with superTypes
Use allSuperTypes when you need the complete inheritance hierarchy. Use superTypes when you only need the types directly inherited by the class.
| Expression | Returns for Mango
|
Use when |
|---|---|---|
Mango.allSuperTypes
|
['Fruit', 'SysSuperClass']
|
You need direct and indirect supertypes. |
Mango.superTypes
|
['Fruit']
|
You need only the immediate parent type or types. |
Notes
- The returned values are type names as strings, not instances of those types.
- This operator follows the inheritance hierarchy upward. It does not return subtypes.
- To work with existing model objects of a classifier, use allInstances instead.
- To test whether an object is of a specified type or one of its subtypes, use oclIsKindOf.
