🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators oclIsKindOf

oclIsKindOf( typespec : Class ) : Boolean

The oclIsKindOf(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.oclIsKindOf(TypeName)

Returns true if:

  • the object is exactly of TypeName, or
  • the object is a subclass of TypeName

Otherwise, it returns false.

Examples:

Expression Result
anEmployee.oclIsKindOf(Employee) true
anEmployee.oclIsKindOf(Person) true
aCat.oclIsKindOf(Person) false


To check if an object has the exact type and does not merely inherit a type, use OCLOperators oclIsTypeOf.