I could write myself a helper class that does this when given a functor, but I was wondering if there’s a better approach, or if there’s something already in the standard library (seems like there should be).
Answers I’ve found on StackOverflow are all for C# which doesn’t help me.
Thanks
No – there isn’t. Apache
commons-collectionshas predicates for this sort of thing but the resultant code (using anonymous inner classes) is usually ugly and a pain to debug.Just use a basic for-loop until they bring closures into the language