Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL, precondition of an operation
OCL, precondition of an operation [message #35339] Mon, 06 August 2007 15:02 Go to next message
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 15:34 Go to previous message
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
Previous Topic:define a operation for a given type.
Next Topic:OCLHelperPackage misses in 2.2 EMF/OCL
Goto Forum:
  


Current Time: Fri Jul 25 23:18:39 EDT 2014

Powered by FUDForum. Page generated in 0.01744 seconds