Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How should max,min handle null case ?
How should max,min handle null case ? [message #1748047] Fri, 18 November 2016 07:27 Go to next message
Roland Bengtsson is currently offline Roland BengtssonFriend
Messages: 1
Registered: November 2013
Junior Member
I have a simple question.
How should Max and Min handle the null case ?

Some examples:

1.
myAttribute.max(5)

myAttribute is an attribute that store an integer value.
But in this case it have a NULL Value ?

Is the correct result 5 ?

2.
myAttribute.min(5)
Is 5 lower than NULL? Or should NULL just be ignored ?
Then the result is also 5.

3
myAttribute.min(myAttribute2)
In this case both myAttribute and myAttribute2 is null.
Logically the result should be null ?

I found no reference to this in documentation
https://wiki.eclipse.org/Acceleo/OCL_Operations_Reference#Number::max_.28_r_:_Number_.29_:_Number
Re: How should max,min handle null case ? [message #1748116 is a reply to message #1748047] Fri, 18 November 2016 15:10 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

The OCL 2.4 specification 11.2.3 makes it clear that all operations involving null are invalid with the exception of a few special functions such as oclIsUndefined(). So null.max(5) is invalid.

The new Pivot OCL JUnit tests include:

ocl.assertQueryInvalid(null, "let i : Integer = null in 1.max(i)");
ocl.assertQueryInvalid(null, "let i : Integer = null in i.max(1)");
ocl.assertQueryInvalid(null, "let r : Real = null in 1.max(r)");
ocl.assertQueryInvalid(null, "let r : Real = null in r.max(1)");

The old Classic OCL (used by Acceleo) JUnit tests include:

assertResultInvalid("let i : Integer = null in 1.max(i)");
assertResultInvalid("let i : Integer = null in i.max(1)");
assertResultInvalid("let r : Real = null in 1.max(r)");
assertResultInvalid("let r : Real = null in r.max(1)");

Regards

Ed Willink
Previous Topic:navigate from a UML class to a UML lifeline/message in an OCL constraint
Next Topic:Performing queries in KDM with OCL
Goto Forum:
  


Current Time: Fri Nov 16 20:40:07 GMT 2018

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

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

Back to the top