Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » ocl operation and parameter type.
ocl operation and parameter type. [message #41594] Thu, 25 October 2007 10:41 Go to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

Hello,

I would like to create an operation in a custom UMLEnvironment, which will be
evaluated with its proper Java method. One of its parameter should accept /any
type/ of parameter. (In java I would have used java.lang.Object)

for example, I would like to make possible to do:
myOperation('a String')
myOperation(Bag{'StringA','StringB')

my problem is that I can't find out any common type for this parameter.

To do the trick, I created two distinct operations to properly handle collection
parameter, but my custom operation is still never matched.

here it is how I declare the type of the parameter:

for a non-collection parameter:
variable.setType(getOCLStandardLibrary().getOclAny())

for a collection parameter:
org.eclipse.ocl.util.TypeUtil.resolveCollectionType(this,
CollectionKind.COLLECTION_LITERAL, getOCLStandardLibrary().getAny)


thanks in advance.

--
F. Lagarde
Re: ocl operation and parameter type. [message #41640 is a reply to message #41594] Thu, 25 October 2007 13:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, François,

OCL collection types are defined as specifically *not* conforming to OclAny
(they are the only exception), so you would need to distinct signatures
anyway. The look-up of collection parameters currently, I think, requires
an EList signature. I suspect that OclAny mapping to Object is not
supported (the only usage so far of OclAny is in the OCL Standard Library
types, for which matching operations to Java is not an issue).

Of course, you can customize the operation signature look-up in your custom
environment, as well, to suit your requirements. However, it seems useful
in general to be able to match OclAny to Object and OCL collections to
their corresponding Java types. Feel free to raise an enhancement for
this. And feel even freer to include a patch! :-)

Cheers,

Christian


François Lagarde wrote:

> Hello,
>
> I would like to create an operation in a custom UMLEnvironment, which will
> be
> evaluated with its proper Java method. One of its parameter should accept
> /any type/ of parameter. (In java I would have used java.lang.Object)
>
> for example, I would like to make possible to do:
> myOperation('a String')
> myOperation(Bag{'StringA','StringB')
>
> my problem is that I can't find out any common type for this parameter.
>
> To do the trick, I created two distinct operations to properly handle
> collection parameter, but my custom operation is still never matched.
>
> here it is how I declare the type of the parameter:
>
> for a non-collection parameter:
> variable.setType(getOCLStandardLibrary().getOclAny())
>
> for a collection parameter:
> org.eclipse.ocl.util.TypeUtil.resolveCollectionType(this,
> CollectionKind.COLLECTION_LITERAL, getOCLStandardLibrary().getAny)
>
>
> thanks in advance.
>
Re: ocl operation and parameter type. [message #41656 is a reply to message #41640] Thu, 25 October 2007 15:08 Go to previous message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 10/25 about 03h, "Christian" (Christian W Damus) wrote:

Christian> Hi, François, OCL collection types are defined as specifically
Christian> *not* conforming to OclAny (they are the only exception), so
Christian> you would need to distinct signatures anyway.

thanks for your prompt reply.

I solved my problem with two distinct methods having two distinct
signatures. Correct type for collection is:

TypeUtil.resolveCollectionType(this, CollectionKind.COLLECTION_LITERAL, getOCLStandardLibrary().getOclAny())

Christian> However, it seems useful in general to be able to match
Christian> OclAny to Object and OCL collections to their corresponding
Christian> Java types.

could be nice, but really don't know how easy is to integrate. I was also facing
to convert Java type to UML type. Maybe an additional helper could be helpful
(for both UML or UML.OCL plugin)

thanks for the quality of this plugin.

--
F. Lagarde
Previous Topic:recursion
Next Topic:[Announce] MDT OCL 1.2.0 I200710251333 is available
Goto Forum:
  


Current Time: Wed Apr 24 22:51:36 GMT 2024

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

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

Back to the top