commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodney Waldhoff <rwaldh...@apache.org>
Subject [functor] changes to EachElement
Date Sat, 19 Jul 2003 22:14:02 GMT
I've just checked in a somewhat significant change to the implementation,
but not the functionality, of EachElement.  Let me describe it for
comment:

Previously EachElement was an instantiable class implementing Generator,
but all the non-static methods simply delegating to some underlying
Generator instance (typically IteratorToGeneratorAdapter).  In other
words, EachElement was nothing more than a proxy/decorator for some other
Generator instance.

The other part of EachElement (that is, the static part) provided
"factory" methods for creating EachElement instances, e.g.,
EachElement.from(someCollection).

Since the instantiable EachElement instance didn't seem to be adding any
value, I've removed it.  Now EachElement is just a container for the
static factory methods (the "from" methods).

Also, I made those factory methods handle null values a bit more robustly,
so that EachElement.from(null) return null, and added tests for this
behavior.

What we've lost, relative to the previous revision of EachElement is:

1) the ability to write something like "new EachElement(someCollection)",
instead one must write "EachElement.from(someCollection)", or if you
really like "new", then "new
IteratorToGeneratorAdapater(someCollection.iterator())".

2) the ability to write something like "new EachElement(generator)", or
even "EachElement.from(generator)".  It's not clear to me why that was
provided in the first place.  new EachElement(generator) simply creates an
equivalent Generator, but with an extra level of indirection.

If someone is strongly opposed to these changes we can always roll back to
the previous revision.

- Rod <http://radio.weblogs.com/0122027/>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message