OCLOperators oclIsKindOf
No edit summary
(Automatically adding template at the end of the page.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This is to if a class is a subclass or a the class itself and not unrelated
=== oclIsKindOf( typespec : Class ) : Boolean ===
[[Category:OCLOperators]]
Returns true if the type of ''self'' corresponds to the type or supertype of typespec - otherwise, returns false. This operation allows users to check the class hierarchy of ''self'' much like they would an instance of Java.
{| class="wikitable"
!Expression
!Result
|-
|anEmployee.oclIsKindOf(Employee)
|true
|-
|anEmployee.oclIsKindOf(Person)
|true
|-
|aCat.oclIsKindOf(Person)
|false
|}
To check if an object has the exact type and not only inherits a type use [[OCLOperators oclIsTypeOf]]
[[Category:OCL General Operators]]
{{Edited|July|12|2024}}

Latest revision as of 15:42, 10 February 2024

oclIsKindOf( typespec : Class ) : Boolean

Returns true if the type of self corresponds to the type or supertype of typespec - otherwise, returns false. This operation allows users to check the class hierarchy of self much like they would an instance of Java.

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

To check if an object has the exact type and not only inherits a type use OCLOperators oclIsTypeOf

This page was edited 94 days ago on 02/10/2024. What links here