commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (COLLECTIONS-182) [collections] Change CollectionUtils.forAllDo to return the Closure
Date Thu, 28 Feb 2013 20:25:15 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart reopened COLLECTIONS-182:
-----------------------------------------

    
> [collections] Change CollectionUtils.forAllDo to return the Closure
> -------------------------------------------------------------------
>
>                 Key: COLLECTIONS-182
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-182
>             Project: Commons Collections
>          Issue Type: Improvement
>    Affects Versions: 3.1
>         Environment: Operating System: All
> Platform: All
>            Reporter: Jim Cakalic
>            Priority: Minor
>             Fix For: 4.0
>
>
> I frequently use CollectionUtils.forAllDo with a Closure that determines some
> kind of aggregate value across the members of the Collection. For example, and
> this is entirely manufactured, say I have an Order with a collection of
> LineItems. Order might use a SumClosure to count the number of actual items (not
> LineItem objects) on the Order or to compute the sum of the LineItems cost. It
> would be convenient in these cases if I could use the return of forAllDo to
> chain method calls like this:
>     public BigDecimal getTotal() {
>         return CollectionUtils.forAllDo(lineItems, new SumTotalClosure()).total();
>     }
> As it is, I have to make do with the somewhat less compact:
>     public BigDecimal getTotal() {
>         SumTotalClosure closure = new SumTotalClosure();
>         CollectionUtils.forAllDo(lineItems, closure);
>         return closure.total();
>     }
> Thanks for considering it.
> Regards,
> Jim Cakalic

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message