commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35955] New: - Change CollectionUtils.forAllDo to return the Closure
Date Mon, 01 Aug 2005 01:21:10 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35955>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35955

           Summary: Change CollectionUtils.forAllDo to return the Closure
           Product: Commons
           Version: 3.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: james.cakalic@charter.net


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

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
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