OCL, precondition of an operation [message #35339] |
Mon, 06 August 2007 19:02 |
Eclipse User |
|
|
|
Originally posted by: kehrer.hdm-stuttgart.de
Hi everybody,
assume we have an operation "op" defined for the UML metaclass Class
(UML::Classes::Kernel::Class).
The operation takes a parameter "param" of type
UML::Classes::Kernel::Property.
The return value is not of interest, let's take Boolean.
The assumtions lead to the following OCL fragment:
context UML::Classes::Kernel::Class::op(param:
UML::Classes::Kernel::Property) : Boolean
Now the precondition should express, that the type of the actual parameter
should be of type Integer.
That is, the operation should only be performed when a property of type
Integer is passed to the operation.
Does anybody have an idea how to express this in OCL?
Thanks in advance,
Timo Kehrer
|
|
|
Re: OCL, precondition of an operation [message #35542 is a reply to message #35339] |
Tue, 07 August 2007 19:34 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Timo,
First, if you are using the MDT UML2 implementation (I will assume that you
are), this implementation provides only the merged UML package
(all-in-one).
So, your constraint would look like:
context uml::Class::op(param : uml::Property) : Boolean
pre param_is_Integer:
param.type = uml::Integer
because the uml package imports the UML primitive types.
However, this won't work in the MDT OCL implementation, because it doesn't
support references to model elements in this way. I'm not even sure that
it should work according to the OCL specification, although it does
recognize references to model elements in some situations (e.g., references
to states and enumeration literals, and types in oclIsKindOf() etc.).
Cheers,
Christian
Timo Kehrer wrote:
> Hi everybody,
>
> assume we have an operation "op" defined for the UML metaclass Class
> (UML::Classes::Kernel::Class).
> The operation takes a parameter "param" of type
> UML::Classes::Kernel::Property.
> The return value is not of interest, let's take Boolean.
> The assumtions lead to the following OCL fragment:
>
> context UML::Classes::Kernel::Class::op(param:
> UML::Classes::Kernel::Property) : Boolean
>
> Now the precondition should express, that the type of the actual parameter
> should be of type Integer.
> That is, the operation should only be performed when a property of type
> Integer is passed to the operation.
> Does anybody have an idea how to express this in OCL?
>
> Thanks in advance,
> Timo Kehrer
|
|
|
Powered by
FUDForum. Page generated in 0.02629 seconds