Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Parameters with generic types.
Parameters with generic types. [message #500598] Thu, 26 November 2009 23:17 Go to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi,
I've been struggeling trying to define an operation with the following signature:

boolean isEnabled(Map<String, ? extends Object> properties);

I have no problem using an EMap<K,V> for the parameter and thus get:

boolean isEnabled(Map<String, Object> properties);

but I have not been able to figure out how to get the '? extends' part in there. I can create a new generic data type as:

Map<K, ? extends Object>

but that doesn't really help. When I use it, I get Map<String, Object extends Object> which of course isn't what I want.
I can cheat and use 'String' as the name of a type variable but that doesn't feel right either. So what is the correct
way of modeling my operation?

Regards,
Thomas Hallgren
Re: Parameters with generic types. [message #500599 is a reply to message #500598] Thu, 26 November 2009 23:48 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
I figured this one out myself. From the looks of it, it's a limitation in the Sample Ecore Model Editor. It's fully
possible to add the following XML to the ecore file:

<eOperations name="isEnabled" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
<eParameters name="properties">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EMap">
<eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eTypeArguments>
<eUpperBound eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
</eTypeArguments>
</eGenericType>
</eParameters>
</eOperations>

and it shows up correctly in the editor. The editor however, does not allow children on the eTypeArguments which begs
the question (that I've been meaning to ask for some time); given that the name of the editor is "Sample ...", is there
a proper Ecore Model Editor somewhere that I'm unaware of? Why is it called "Sample"?

Regards,
Thomas Hallgren



On 2009-11-27 00:17, Thomas Hallgren wrote:
> Hi,
> I've been struggeling trying to define an operation with the following
> signature:
>
> boolean isEnabled(Map<String, ? extends Object> properties);
>
> I have no problem using an EMap<K,V> for the parameter and thus get:
>
> boolean isEnabled(Map<String, Object> properties);
>
> but I have not been able to figure out how to get the '? extends' part
> in there. I can create a new generic data type as:
>
> Map<K, ? extends Object>
>
> but that doesn't really help. When I use it, I get Map<String, Object
> extends Object> which of course isn't what I want. I can cheat and use
> 'String' as the name of a type variable but that doesn't feel right
> either. So what is the correct way of modeling my operation?
>
> Regards,
> Thomas Hallgren
Re: Parameters with generic types. [message #500665 is a reply to message #500599] Fri, 27 November 2009 11:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30633
Registered: July 2009
Senior Member
Thomas,

Did you enable "Show Generics"? The Ecore Tools project provides a
graphical editor that's nicer...


Thomas Hallgren wrote:
> I figured this one out myself. From the looks of it, it's a limitation
> in the Sample Ecore Model Editor. It's fully possible to add the
> following XML to the ecore file:
>
> <eOperations name="isEnabled" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
> <eParameters name="properties">
> <eGenericType eClassifier="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EMap">
> <eTypeArguments eClassifier="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eTypeArguments>
> <eUpperBound eClassifier="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/>
> </eTypeArguments>
> </eGenericType>
> </eParameters>
> </eOperations>
>
> and it shows up correctly in the editor. The editor however, does not
> allow children on the eTypeArguments which begs the question (that
> I've been meaning to ask for some time); given that the name of the
> editor is "Sample ...", is there a proper Ecore Model Editor somewhere
> that I'm unaware of? Why is it called "Sample"?
>
> Regards,
> Thomas Hallgren
>
>
>
> On 2009-11-27 00:17, Thomas Hallgren wrote:
>> Hi,
>> I've been struggeling trying to define an operation with the following
>> signature:
>>
>> boolean isEnabled(Map<String, ? extends Object> properties);
>>
>> I have no problem using an EMap<K,V> for the parameter and thus get:
>>
>> boolean isEnabled(Map<String, Object> properties);
>>
>> but I have not been able to figure out how to get the '? extends' part
>> in there. I can create a new generic data type as:
>>
>> Map<K, ? extends Object>
>>
>> but that doesn't really help. When I use it, I get Map<String, Object
>> extends Object> which of course isn't what I want. I can cheat and use
>> 'String' as the name of a type variable but that doesn't feel right
>> either. So what is the correct way of modeling my operation?
>>
>> Regards,
>> Thomas Hallgren
>
Previous Topic:Problems to locate a resource
Next Topic:Issue with References when upgrading to 2.5
Goto Forum:
  


Current Time: Fri Nov 15 07:30:02 GMT 2019

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

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

Back to the top