PLEASE HELP!!

Im begging you people!

publicfinalclass Bundle<Eextends BundleElement, Fextends ID>implements IBundle<E, F>

publicboolean doesElementExist(F pID)

{

return (lookupIndex(pID) != (-1));

}

publicboolean doesElementExist(E pItem)

{

return doesElementExist(pItem.getID());

}

ID class:

import java.io.Serializable;

publicinterface IDextends Serializable

{

public String asText();

publicboolean doesMatch(ID pID);

}

The compiler flags the line

'return doesElementExist(pItem.getID());

as an error after inserting generics; is there any way to tell it that type parameter F is always an ID; and pItem.getID() always returns an ID; so why does it refuse to take the ID and store it in F?

[1605 byte] By [alanpza] at [2007-10-2 5:30:01]
# 1
You're not allowed two methods with the same erasure.
YAT_Archivista at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 2
they dont have same erasure though surely... E extends BundleElementF extends IDThey erase to different things?
alanpza at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 3
Yes. Sorry. What's the precise text of the error message?
YAT_Archivista at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 4

> The compiler flags the line

>

> 'return doesElementExist(pItem.getID());

>

> as an error after inserting generics; is there any

> way to tell it that type parameter F is always an ID;

> and pItem.getID() always returns an ID; so why does

> it refuse to take the ID and store it in F?

Type Parameter E is erased to BundleElement, thus pItem.getID() returns an ID. Why should this match public boolean doesElementExist(F pID) where F is an arbitrary subclass of ID?

You could solve this by generifying BundleElement as shown below.public final class Bundle<E extends BundleElement><F>, F extends ID> implements IBundle<E, F>

public boolean doesElementExist(F pID)

{

return (lookupIndex(pID) != (-1));

}

public boolean doesElementExist(E pItem)

{

return doesElementExist(pItem.getID());

}

interface BundleElement<F extends ID> {

public F getID();

}

McNeppa at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 5
I love you people!Thanks
alanpza at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 6
erm... how do I assign points?
alanpza at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...
# 7
you should have a button to reward a response with
darteda at 2007-7-16 1:31:33 > top of Java-index,Core,Core APIs...