Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Check for an existing reference
Check for an existing reference [message #491076] Tue, 13 October 2009 03:29 Go to next message
Timothy Marc is currently offline Timothy Marc
Messages: 547
Registered: July 2009
Senior Member
Hey all,

what is the beste way to check whether a reference is not null? What i
want to define is a constraint, that if one end of an binary reference
is set, the other side has to be set as well.

Both binary ends have the multiplicity 0 .. 1.

I have two different approaches:

1. context Class1 inv: self.sideA <> null implies self.sideB <> null
2. context Class1 inv: self.sideA.notEmpyt() implies self.sideB.notEmpty()
3. context Class1 inv: self.sideA->size() = 1 implies self.sideB->size() = 1

What is the best approach?!

Thanks Timothy
Re: Check for an existing reference [message #491326 is a reply to message #491076] Wed, 14 October 2009 03:29 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4027
Registered: July 2009
Senior Member
Hi Timothy

If you want to test for not-null, testing for not-null seems like a good
approach.

not-empty and not-null are different concepts.

Regards

Ed Willink

Timothy Marc wrote:
> Hey all,
>
> what is the beste way to check whether a reference is not null? What i
> want to define is a constraint, that if one end of an binary reference
> is set, the other side has to be set as well.
>
> Both binary ends have the multiplicity 0 .. 1.
>
> I have two different approaches:
>
> 1. context Class1 inv: self.sideA <> null implies self.sideB <> null
> 2. context Class1 inv: self.sideA.notEmpyt() implies self.sideB.notEmpty()
> 3. context Class1 inv: self.sideA->size() = 1 implies self.sideB->size()
> = 1
>
> What is the best approach?!
>
> Thanks Timothy
Previous Topic:Extending OCL standard library with function returning Sequence(T)
Next Topic:OCL 2.1 Spec available?
Goto Forum:
  


Current Time: Fri Aug 22 19:52:53 EDT 2014

Powered by FUDForum. Page generated in 0.01838 seconds