stipulate that a parameterised type must implement an interface
843793Sep 25 2007 — edited Sep 27 2007Hi,
1000 excuses if this has been asked before:
I want to say "abstract class AbstractHolder<Y>" and also say "oh by the way, Y must implement interface Snodgrass"
In other words I want to limit the kind of subelements which are held by the AbstractHolder so that an attempt to establish an AbstractHolder subclass which holds subelements which do not implement Snodgrass results in a compiler error.
Of course you can put in an "instanceof" check in the constructor... but I think generics should enable you to say "abstract class AbstractHolder<Y implements Snodgrass>"... they don't appear to...
Anything to be done?
Thanks - MRodent