16

Is there a viable generic version of org.apache.commons.collections.CollectionUtils? If not, why not? It seems like an obvious need. Or has the Java community just given up on functional coding until closures are added to Java 17?

skaffman
  • 398,947
  • 96
  • 818
  • 769
kevin cline
  • 2,608
  • 2
  • 25
  • 38

2 Answers2

13

Looks like situation around Apache Commons Collections has changed. API version 4.0 is strongly typed. It is already available in Maven Central Repository.

JeanVEGA
  • 141
  • 1
  • 5
13

There's a genericified port of a slightly out-of-date version of Commons Collections here. It's no longer maintained, however.

A better option is Google Guava. It has classes like Lists, Sets, Collections2 etc that are the equivalent to Commons' CollectionUtils. Guava is not a one-for-one port of Commons Collections, but it has a better designed and more consistent API. Takes a bit of adjusting to, if you're used to Commons Collections.

skaffman
  • 398,947
  • 96
  • 818
  • 769