commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita" <brunodepau...@yahoo.com.br>
Subject [functor] Rename CollectionTransformer and update javadocs
Date Thu, 20 Sep 2012 03:36:20 GMT
Hi all,


There is one item pending from the last poll to release [functor], regarding a TODO in CollectionTransformer.
Excerpt below: 


     * TODO revisit this class... it could stand a more-descriptive name.  Also, it's
a little
     * hard to say whether, for an instance constructed without a specific target collection,
     * #evaluate() should return a new ArrayList for each call, or continue adding to
     * a single ArrayList instance (the current behavior).
     * Perhaps this is more a documentation issue than anything.

And the comments on the TODO items.


> it could stand a more-descriptive name.

I'm +0 to rename. The only name that I could think of was GeneratorToCollectionTransformer,
but found some on the Internet after looking for 'convert generator to iterator' and 'convert
generator to list': Listify, Eagerlize and Lazy List Builder. 


I liked Lazy List Builder, as this class creates a list from a given generator, but only when
you call the evaluate(Generator) method (lazily initializing the list). Anyone has other thoughts
on this? 


> Also, it's a little hard to say whether, for an instance constructed without a specific
target collection,
> #evaluate() should return a new ArrayList for each call, or continue adding to
> a single ArrayList instance (the current behavior).

The constructor doesn't return a new ArrayList for each call anymore. Now it validates whether
the list is null or not null, throwing an exception if the former is true. 


After an instance of CollectionTransformer is created, for every call of evaluate(Generator)
it adds the generator elements to the given list. It means that if you call the evaluate method
10 times, it will return the same list with more elements. 


I'm +1 for changing this behaviour too and returning a new list for each call of evaluate(Generator).
This way we don't have to worry about multiple threads accessing the same list object. If
nobody is against this I will file an issue to work on this. 

Finally, the javadocs are out of date, so I would like to update it with our consensus on
these items :-)

Many thanks in advance!


Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com 

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


Mime
View raw message