Re: My idea for filtering an Enumeration or Iterator
- From: rem642b@xxxxxxxxx (Robert Maas, see http://tinyurl.com/uh3t)
- Date: Wed, 27 Jul 2005 22:15:59 -0700
> From: angrybaldguy@xxxxxxxxx
> Enumerations aren't available on the most common collection
> interfaces in java.util (List, Set, and Map).
That seems to be a rather moot point, considering that:
(1) Given any specific implementation of such an interface, it's rather
trivial to sub-class it to implement an enumeration for that class. So
then you declare your objects to be of that sub-class instead of the
API class.
(2) If you absolutely need a generic class that includes more than one
such sub-classed implementation class, with objects declared to be
ambiguously of the generic class instead of specifically of one of the
various implementation classes, and you absolutely need Enumeration to
be defined over that whole generic class instead of just over each
specific implementation, so that you can compile Enumeration code that
doesn't care which implementation class happens at runtime, you can
make a runtime interface as I demonstrated a few weeks ago.
Also, I prefer "weak enumerations" instead anyway. Single method
getNext or whatever which returns a default EOF value when it's reached
the end, otherwise returns the next item in the sequence, avoiding the
need to first test isNext and then somehow trust it when in fact it
sometimes lies and getNext then throws exception due to the bug.
> While I don't like the idea of "optional" members of interfaces
> (preferring subinterfaces), there is precedent for it in the Java APIs.
There's precedent for a whole lot of bad ideas. They should all be
deprecated rather than glorified as examples to emulate elsewhere.
.
- Prev by Date: Re: isErrorPage is not working in Tomcat 5.5 !
- Next by Date: change log comments
- Previous by thread: Running RMI Server on Different Port - binding issues
- Next by thread: change log comments
- Index(es):
Relevant Pages
|
|