Skip to main content



      Home
Home » Modeling » EMF » Parameters with generic types.
Parameters with generic types. [message #500598] Thu, 26 November 2009 18:17 Go to next message
Eclipse UserFriend
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 18:48 Go to previous messageGo to next message
Eclipse UserFriend
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 06:48 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 11:12:39 EDT 2025

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

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

Back to the top