Is there a viable generic alternative to apache.commons.collections.CollectionUtils?

久未见 提交于 2019-12-08 14:47:00

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7015739/is-there-a-viable-generic-alternative-to-apache-commons-collections-collectionut

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!