@yegor256 Yes it really does.:/ Only reason I added that code was not to have a 3rd party lib included (I think I read somewhere here we want to minimize that). 

What about Commons Collections, i.e. http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.1/org/apache/commons/collections/CollectionUtils.html#size(java.lang.Object)? The dependency is smaller, and it does what we'd like to?