Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Genericized commons collection

I'm astonished that the Apache Commons Collections project still hasn't got around to making their library generics-aware. I really like the features provided by this library, but the lack of support for generics is a big turn-off. There is a Lavalabs fork of Commons Collections which does support generics, which seems to claim backward compatibility, but when I tried updating to this version, my web application failed to start (in JBoss).

My questions are:

  • Whether anyone has successfully updated from Commons Collections to the fork mentioned above
  • If Commons Collections has any plans to add support for generics

BTW, I'm aware of Google collections, but am reluctant to use it until the API stabilises.

Cheers, Don

like image 474
Dónal Avatar asked Nov 17 '08 16:11

Dónal


People also ask

What is Commons collections4?

Description. org.apache.commons.collections4. This package contains the interfaces and utilities shared across all the subpackages of this component. org.apache.commons.collections4.bag. This package contains implementations of the Bag and SortedBag interfaces.

Does CollectionUtils isNotEmpty check for NULL?

isNotEmpty() method of CollectionUtils can be used to check if a list is not empty without worrying about null list. So null check is not required to be placed everywhere before checking the size of the list.

What is Java CollectionUtils?

Simply put, the Apache CollectionUtils provides utility methods for common operations which cover a wide range of use cases and helps in avoiding writing boilerplate code. The library targets older JVM releases because currently, similar functionality is provided by the Java 8's Stream API.


1 Answers

Consider Google Collections. From their Javalobby interview:

[Google Collections is] built with Java 5 features: generics, enums, covariant return types, etc. When writing Java 5 code, you want a collections library that takes full advantage of the language. In addition, we put enormous effort into making the library complete, robust, and consistent with the JDK collection classes.

like image 121
Jesse Wilson Avatar answered Nov 06 '22 22:11

Jesse Wilson