OCLOperators oclIsTypeOf
This page was created by Alexandra on 2017-08-13. Last edited by 62.169.16.147 on 2026-09-12.
oclIsTypeOf( typespec : Class ) : Boolean[edit source]
The oclIsType(T) operator checks whether an object is of a given type or any of its subtypes. It is mainly used in models with inheritance to safely test an object’s runtime type.
Syntax
object.oclIsTypeOf(TypeName)The above ;
- Returns true if the object is exactly of the specified type
- Returns false if the object is of a subtype (child class)
Example of Expressions
| Expression | Result |
|---|---|
| anEmployee.oclIsTypeOf(Employee) | true |
| anEmployee.oclIsTypeOf(Person) | false |
| aCat.oclIsTypeOf(Person) | false |
Example
obj.oclIsTypeOf(TrainingProgram )Results:
