Skip to main content


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 07:29 Go to next message
Timothy Marc is currently offline Timothy MarcFriend
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 07:29 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 Apr 19 14:49:18 GMT 2024

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

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

Back to the top