Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Reflection example
Reflection example [message #1321640] Tue, 29 April 2014 12:01 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 284
Registered: March 2012
Senior Member
Hi,

I was asked for examples that use reflection in OCL. Not being sure if
possible at all, and with a lack of ideas, I hope for help from the list.

class MyClass
property x : Integer[0..*]

Want to express this (semantic nonsense) example in OCL:

If MyClass.x.isUnique = true, then all elements in x should be < 0.

Is this possible? The key question is if/how can I access the 'isUnique'
property on an instance of MyClass.


I would also be grateful for any example that is a little more
meaningful. I ordered the book by Warner/Klepekke, and hope to find
something there, but I'm pessimistic.

Thanks,
Felix
Re: Reflection example [message #1321667 is a reply to message #1321640] Tue, 29 April 2014 12:21 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4184
Registered: July 2009
Senior Member
Hi

There is no explicit support for reflection in OCL < 2.5.

However there are some indications that it is present; e.g oclType()
seems a bit reflective and the post condition for flatten:

post: result = if self.oclType().elementType.oclIsKindOf(CollectionType)
then

are difficult to interpret without reflection.

The RFP for OCL 2.5 request submissions to provide a solution to reflection.

The Pivot-based Ocl implementation is fully reflective.

So perhaps

MyClass.ownedAttribute->select(name = 'x').isUnique

or

myClass.oclType().ownedAttribute->select(name = 'x').isUnique

The intention is that oclType() should be rather like getClass() in Java
but with a stronger type return.

Regards

Ed Willink

On 29/04/2014 13:01, Felix Dorner wrote:
> Hi,
>
> I was asked for examples that use reflection in OCL. Not being sure if
> possible at all, and with a lack of ideas, I hope for help from the list.
>
> class MyClass
> property x : Integer[0..*]
>
> Want to express this (semantic nonsense) example in OCL:
>
> If MyClass.x.isUnique = true, then all elements in x should be < 0.
>
> Is this possible? The key question is if/how can I access the
> 'isUnique' property on an instance of MyClass.
>
>
> I would also be grateful for any example that is a little more
> meaningful. I ordered the book by Warner/Klepekke, and hope to find
> something there, but I'm pessimistic.
>
> Thanks,
> Felix
Previous Topic:Wrong implication evaluation in OCL 5
Next Topic:Using 'literal value' elements in OCL expressions
Goto Forum:
  


Current Time: Thu Dec 18 12:42:35 GMT 2014

Powered by FUDForum. Page generated in 0.01589 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software