What's the best way to do null-safe contains on a Java collection?
in other words -
if (collection != null && collection.contains(x))
?
I was hoping Apache commons-collections had something like CollectionUtils.contains(collection, x) that would simply return false if the collection was null, as there is with size(), which treats null like an empty collection.
However, it seems like there is no such thing - did I just miss it?