🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators oclIsKindOf
This page was created by Alexandra on 2017-08-13. Last edited by Wikiadmin on 2026-07-29.

You can use oclIsKindOf in an OCL expression to test whether an object is an instance of a specified class or of any class derived from it.

Syntax

object.oclIsKindOf(TypeName)

TypeName is the class that you want to test against. The operator returns a Boolean value.

Result When it is returned
true The object has the specified type, or its runtime type is a subtype of the specified type.
false The object does not have the specified type and is not an instance of a subtype of that type.

Use it with inheritance

Use oclIsKindOf when a class hierarchy is relevant and you want a test that includes derived classes.

For example, assume that Employee is a class and Manager is a subclass of Employee:

anEmployee.oclIsKindOf(Employee)

This expression returns true when anEmployee is an Employee. It also returns true when the runtime object is a Manager, because Manager inherits from Employee.

If the object is instead an instance of an unrelated class, the expression returns false.

Compare exact-type testing

oclIsKindOf includes subtypes. Use oclIsTypeOf when you need to test for the exact runtime type and do not want derived classes to match.

Operator Matches the specified class Matches subclasses of the specified class
oclIsKindOf(TypeName) Yes Yes
oclIsTypeOf(TypeName) Yes No

Find operators in the OCL Editor

To inspect the operators available for a class, open the OCL Editor and type the class name. See OCL General Operators for guidance on finding available operators.

See also