🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators oclIsTypeOf
Created by Alexandra on 2017-08-13 · Last edited by Colline.ssali on 2026-03-27.

oclIsTypeOf( typespec : Class ) : Boolean

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:

Documentation OCLOperators oclIsTypeOf 1774608999316.png