help with generics
From: David (david.kensche_at_post.rwth-aachen.de)
Date: 09/29/04
- Previous message: RC: "Re: tomcat5+apache2+mod_jk2"
- Next in thread: Larry Barowski: "Re: help with generics"
- Reply: Larry Barowski: "Re: help with generics"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Sep 2004 05:32:00 -0700
Hello,
I try to model the following structure:
A DomainModel has several Concepts as sons and
a Concept has several Categories as sons and
a Category may also have Categories as sons.
I modeled it like that:
public abstract class DomainModelElement<C extends DomainModelElement>
implements DomainModelTokens {
protected Vector<C> children = new Vector<C>();
..
public class DomainModel extends DomainModelElement<Concept> {
..
public class Concept extends DomainModelElement<Category> {
..
public class Category extends DomainModelElement<Category> {
..
So I pass the child type to the element, so I can use generic
implementations
of the methods for accessing the children. When I compile everything
works fine
until the compiler see the Category class. It says:
Bound mismatch: The type Category is not a valid substitute for the
bounded parameter <C extends DomainModelElement> of the type
DomainModelElement<C> Category.java
although Category is a subclass of DomainModelElement<C>.
Can anybody help?
Thanks beforehand,
David Kensche
- Previous message: RC: "Re: tomcat5+apache2+mod_jk2"
- Next in thread: Larry Barowski: "Re: help with generics"
- Reply: Larry Barowski: "Re: help with generics"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]