Re: Generics ?
On 12/17/2011 2:40 PM, Knute Johnson wrote:
[...]
Thanks Pete. That's obvious now but wasn't yesterday :-). You know I
looked all over the net for examples of extending a generic class and
found none. It could be that I didn't know what I was looking for really.
Next time something of this sort arises, it may be helpful to
ask "Does Java itself provide an example of what I'm trying to do?"
In the case at hand, you might have found
ArrayList<E> extends AbstractList<E> implements List<E> ...
AbstractList<E> extends AbstractCollection<E> ...
AbstractCollection<E> implements Collection<E> ...
.... illustrating how a generic class can extend a generic class
and/or implement a generic interface.
The wrong thing to do with the Java source is to ask "If a JFoo
has multiple FooListeners, which is the first to be sent a FooEvent?"
because that's the sort of implementation detail that might change
without notice. But one of the right things to do with Java source
is to look at the JFoo implementation to see how it dispatches to the
FooListeners, so you can use that pattern as an example when writing
the Knute class to dispatch KnuteEvents to KnuteListeners.
--
Eric Sosman
esosman@ieee-dot-org.invalid