Reflection example [message #1321640] |
Tue, 29 April 2014 08:01  |
Eclipse User |
|
|
|
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 08:21  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03326 seconds