Re: Instance of in OCL!



Re: Instance of in OCL!

From: Vladimir Mencl ^lt;mencl@nenya.ms.mff.cuni.cz>
Date: Sun 16 Apr 2006 - 09:19:20 BST
Message-ID: <4441FE08.1090707@nenya.ms.mff.cuni.cz>
On 04/16/2006 02:50 AM, Milan Milanovic wrote:
> How to represent instance of relation in OCL ? Is it possible ?
>  

Yes it is.

There are two built-in functions defined on each type, oclIsTypeOf and 
oclIsKindOf.

Quoting from Sect. 2.5.9 of ad/02-05-09
   oclIsTypeOf (t : OclType) : Boolean
   oclIsKindOf (t : OclType) : Boolean

   The operation is oclIsTypeOf results in true if the type of self and t
   are the same.

   The oclIsKindOf property determines whether t is either the direct type
   or one of the supertypes of an object.


Depending on whether you want the instanceof relation to include 
subclassing, either the oclIsTypeOf or oclIsKindOf operation should do 
what you want (the latter one will behave as the Java instanceof operator).

Best Regards,
Vladimir



> e.g. like in java object instanceOf Class
> 
Received on Sun Apr 16 09:19:44 2006