Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Java Generics Code Generation
Java Generics Code Generation [message #431086] Fri, 26 June 2009 01:43 Go to next message
Chris Graham is currently offline Chris GrahamFriend
Messages: 4
Registered: July 2009
Junior Member
Hello,

I'm trying to model a simple list using Java generics but am so far unable
to get eclipse to generate the code correctly. What I want to do is create
the following:

public class List<E> extends EObjectImpl implements EObject {
public void add(E x) {}
}


public class ConcreteList extends EObjectImpl implements MyList<Class> {
public void add(Class x) {
}

but I can only get it to create:

public class List<E> extends EObjectImpl implements EObject {
public void add(E x) {}
}

public class ConcreteList extends EObjectImpl implements MyList {
public void add(E x) {
}

How do I get the concreate list class to replace the generic <E> with a
concreate class in the ConcreteList?

-- Chris Graham
Re: Java Generics Code Generation [message #431088 is a reply to message #431086] Fri, 26 June 2009 03:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Chris,

Comments below.

Chris Graham wrote:
> Hello,
>
> I'm trying to model a simple list using Java generics
Simple being a relative term here...
> but am so far unable to get eclipse to generate the code correctly.
Correctly being relative to your expectation....
> What I want to do is create the following:
>
> public class List<E> extends EObjectImpl implements EObject {
> public void add(E x) {}
> }
This seems problematic to me. List has a specific requirement for the
implementation of hashCode and equals which conflicts with the specific
requirement for equals and hashCode for EObject.
>
>
> public class ConcreteList extends EObjectImpl implements MyList<Class> {
> public void add(Class x) {
> }
>
> but I can only get it to create:
And how did you get it to do that?
>
> public class List<E> extends EObjectImpl implements EObject {
> public void add(E x) {}
> }
>
> public class ConcreteList extends EObjectImpl implements MyList {
> public void add(E x) {
> }
>
> How do I get the concreate list class to replace the generic <E> with
> a concreate class in the ConcreteList?
My brain is a little sore after than sentence. I don't think there's
enough context to answer your question. As I suggested initially, an
EObject that's also a List is contradictory...
>
> -- Chris Graham
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Java Generics Code Generation [message #431480 is a reply to message #431088] Mon, 13 July 2009 05:01 Go to previous message
Chris Graham is currently offline Chris GrahamFriend
Messages: 4
Registered: July 2009
Junior Member
Hello Ed,

Thanks for your response and I apologise for my confusing post.

I've decided to abandon the inheritance approach but still have an issue
very similar to the one recently added by Gary Thompson
( http://www.eclipse.org/newsportal/article.php?id=42889&g roup=eclipse.tools.emf#42889)

So I've decided to post a response to Gary's problem rather than continue
on this separate thread as our issues seem rather similar.

-- Chris Graham
Previous Topic:EMF List databinding
Next Topic:[CDO] Marketing
Goto Forum:
  


Current Time: Fri Apr 19 21:28:09 GMT 2024

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

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

Back to the top