Can't extend parameters in nested setup

Hi,

I've got some classes that look like:

publicclass WorkingSetCache<K, V>implements Runnable{...}

publicclass DatabaseCache<K, Vextends PersistentBusinessObject>extends WorkingSetCache<K, V>{...}

publicinterface Cacheable<K, Vextends PersistentBusinessObject >{}

I'd like to have the V in DatabaseCache be Cacheable with all the type safety from the basic declaration. But I'm not having any success figuring out what it should be. The code fragments above work, but then I have to doinstanceof and casts to use functions declared in Cacheable.

The semantics should be that you can declare a

DatabaseCache<Integer, Foo> theCache =new DatabaseCache<Integer, Foo>();

where Foo is a cachable, Persistant object, and there is an Integer key into the cache.

I'm clearly missing something, and would greatly appreciate pointers.

[1464 byte] By [fishtop_recordsa] at [2007-11-26 17:41:22]
# 1

Do you mean

public class DatabaseCache<K, V extends PersistentBusinessObject & Cacheable><K, V>> extends WorkingSetCache<K, V> {...}

dannyyatesa at 2007-7-9 0:09:34 > top of Java-index,Core,Core APIs...
# 2

I'm not sure what your form, with the ampersand means.

What I am trying to do is to starting with

public class WorkingSetCache<K, V> implements Runnable {...}

public class DatabaseCache<K, V extends PersistentBusinessObject> extends WorkingSetCache<K, V> {...}

public interface Cacheable<K, V extends PersistentBusinessObject > {}

then have a class, say Resident which is declared as

public class Resident extends PersistentBusinessObject implements Cacheable<Integer, Resident> {}

This says that Resident is a PersistentBusinessObject and it is cachable, with the key being an Integer and the 'object' of the hashmap being a Resident

So the use/declaration of a parametered DatabaseCache would look like

DatabaseCache<Integer, Resident> theCache = new DatabaseCache<Integer, Resident>();

But with the declarations I have shown above, the

public class DatabaseCache<K, V extends PersistentBusinessObject>

only states that my "theCache" is using a Resident, which is a PersistentBusinessObject, while it is also Cachable.

The 'Cachable' part is lost, so I can't call the functions declared in the Cachable interface without an ugly cast.

Seems that proper declaration will let me say that V is both 'is a" PersistantBusinessObject and "implements" Cachable

fishtop_recordsa at 2007-7-9 0:09:34 > top of Java-index,Core,Core APIs...
# 3
> I'm not sure what your form, with the ampersand means.See below.> Seems that proper declaration will let me say that V> is both 'is a" PersistantBusinessObject and> "implements" CachableThat's what the ampersand does.
ejpa at 2007-7-9 0:09:34 > top of Java-index,Core,Core APIs...
# 4
Wow, that is great. It works perfectly.Thanks a lot.Do you have a link to some documentation on this? I searched and searched and could not find this.Thanks again
fishtop_recordsa at 2007-7-9 0:09:34 > top of Java-index,Core,Core APIs...