commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject [collections] Number of elements matching a Predicate
Date Sun, 24 Nov 2002 21:28:02 GMT

Proposal is to add a method (or four) to return true if all/none/one or more
of the elements match the predicate.

Anyone got any views on this? I'm minded to reject it as not adding enough
to the API, eg.

     * Returns <code>true</code> if all the elements in the input collection
     * match the specified predicate.
     * @param inputCollection  the collection to get the input from, may not
be null
     * @param predicate  the predicate to use, may be null
     * @return true if all elements match the predicate
     * @throws NullPointerException if the input collection is null
    public static boolean matchesAll(Collection inputCollection, Predicate
predicate) {
        return select(inputCollection, predicate).size() ==

ie. the code isn't very much, but is the method signature clearer?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message