Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » problems with enums and generics
problems with enums and generics [message #426402] Fri, 02 January 2009 22:12 Go to next message
klaus wiederaenders is currently offline klaus wiederaendersFriend
Messages: 1
Registered: July 2009
Junior Member
HI,

Given the interface:

package emf.generics;
/** @model */
public interface Command<C> {
}


Now consider the following enum:

package emf.generics;
/** @model */
public enum LampCommand implements Command<LampCommand> {
OFF,
ON,
BLINK;
}

The model enum generated starts like this:

/** @model */
public enum LampCommand implements Enumerator {
...

Where is the implements Command<LampCommand> gone?


Furthermore, the generated model for the interfaces below
still shows up the problems already described in:

http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 4332.html
and bugzilla 209420.


Here the Java code:

package emf.generics;
/** @model */
public interface Element<C extends Command<C>> {
/** @model */
void execute( C command );
}

package emf.generics;
/** @model */
public interface Lamp extends Element<LampCommand> {
}

After a little patching things can be compiled.

Thank you,
Klaus
Re: problems with enums and generics [message #426404 is a reply to message #426402] Sat, 03 January 2009 11:30 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090609090304040709000900
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Klaus,

Comments below.

klaus wiederanders wrote:
> HI,
>
> Given the interface:
>
> package emf.generics;
> /** @model */
> public interface Command<C> {
> }
>
>
> Now consider the following enum:
>
> package emf.generics;
> /** @model */
> public enum LampCommand implements Command<LampCommand> {
> OFF,
> ON,
> BLINK;
> }
>
> The model enum generated starts like this:
>
> /** @model */
> public enum LampCommand implements Enumerator {
> ..
>
> Where is the implements Command<LampCommand> gone?
EEnums are EDataTypes and the don't support having eSuperTypes the way
EClasses do.

You'll need to add

@implements Command<LampCommand>

so that JMerger will inject this non-modeled information into the result.
>
>
> Furthermore, the generated model for the interfaces below
> still shows up the problems already described in:
>
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 4332.html
> and bugzilla 209420.
>
>
> Here the Java code:
>
> package emf.generics;
> /** @model */
> public interface Element<C extends Command<C>> {
> /** @model */
> void execute( C command );
> }
>
> package emf.generics;
> /** @model */
> public interface Lamp extends Element<LampCommand> {
> }
Given that LampCommand is not an EClass and hence is not known to extend
Command, it's a valid conclusion about what's actually been captured in
the Ecore model.

The @implements can be used to "remove" this from the model as well.

Making EEnums be like EClasses with inheritance is simply beyond what's
intended to be possible with Ecore...
>
> After a little patching things can be compiled.
>
> Thank you,
> Klaus
>
>

--------------090609090304040709000900
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Klaus,<br>
<br>
Comments below.<br>
<br>
klaus wiederanders wrote:
<blockquote
cite="mid:5bda6f89056a92915189f6c4ec490ea7$1@www.eclipse.org"
type="cite">HI,
<br>
<br>
Given the interface:
<br>
<br>
package emf.generics;
<br>
/** @model */
<br>
public interface Command&lt;C&gt; {
<br>
}
<br>
<br>
<br>
Now consider the following enum:
<br>
<br>
package emf.generics;
<br>
/** @model */
<br>
public enum LampCommand implements Command&lt;LampCommand&gt; {
<br>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Wired namespace issue
Next Topic:Minimizing Ecore on XSD/WSDL import
Goto Forum:
  


Current Time: Fri Apr 19 20:40:39 GMT 2024

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

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

Back to the top