Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Referencing to OCL constraint
Referencing to OCL constraint [message #898426] Thu, 26 July 2012 11:27 Go to next message
Wouter Schaekers is currently offline Wouter Schaekers
Messages: 17
Registered: July 2012
Junior Member
Hi.

I was wondering whether it is possible to reference to an OCL constraint in a derivation property/attribute. To give a simple example:

Invariant Bigger:
self.num > 5;

Now I want to use 'Bigger' in a derivation. Eg:

derivation: if Bigger then ... else ... endif

Is this possible or do I have to do double work?
Thanks.
Re: Referencing to OCL constraint [message #898463 is a reply to message #898426] Thu, 26 July 2012 12:21 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4110
Registered: July 2009
Senior Member
HI

Yes/No.

Ecore supports two kinds of invariant, one callable, one not.

Using the OCLinEcore editor you can annotate an invariant as 'callable'.

But an invariant is always/true/false on a valid/invalid model, so it
makes no sense to use it in an if.

If you want a re-useable expression, warp it as an operation or property.

property isBigger : Boolean {transient, volatile} { derivation:
self.num > 5; }
invariant Bigger: isBigger;

....

Regards

On 26/07/2012 12:27, Wouter Schaekers wrote:
> Hi.
>
> I was wondering whether it is possible to reference to an OCL
> constraint in a derivation property/attribute. To give a simple example:
>
> Invariant Bigger:
> self.num > 5;
>
> Now I want to use 'Bigger' in a derivation. Eg:
>
> derivation: if Bigger then ... else ... endif
>
> Is this possible or do I have to do double work?
> Thanks.
Re: Referencing to OCL constraint [message #898474 is a reply to message #898463] Thu, 26 July 2012 12:52 Go to previous message
Wouter Schaekers is currently offline Wouter Schaekers
Messages: 17
Registered: July 2012
Junior Member
Ed Willink wrote on Thu, 26 July 2012 08:21
But an invariant is always/true/false on a valid/invalid model, so it
makes no sense to use it in an if.

That sounds very logical. Smile

Ed Willink wrote on Thu, 26 July 2012 08:21
If you want a re-useable expression, warp it as an operation or property.

property isBigger : Boolean {transient, volatile} { derivation:
self.num > 5; }
invariant Bigger: isBigger;

This works. Thanks.

[Updated on: Thu, 26 July 2012 12:52]

Report message to a moderator

Previous Topic:Package as Ocl Context
Next Topic:Concat collection
Goto Forum:
  


Current Time: Thu Oct 30 18:16:37 GMT 2014

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

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