I wanted to test equality between 2 list and found CollectionUtils.isEqualCollection. It says on API: Returns true iff the given Collections contain exactly the same elements with exactly the same cardinalities.
what cardinalities exactly are? I couldn't find good explanation about it.
Thanks in advance!
Apache Commons CollectionUtils emptyIfNull(final Collection<T> collection) Returns an immutable empty collection if the argument is null, or the argument itself otherwise.
Based on CollectionUtils. cardinality() : Returns the number of occurrences of obj in coll . I'd say it returns true if and only if they have the same elements, the same number of times. Take a look here, around line 514.
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.
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.
Based on CollectionUtils.cardinality()
:
Returns the number of occurrences of
obj
incoll
.
I'd say it returns true if and only if they have the same elements, the same number of times.
Take a look here, around line 514. It seems the order of the elements doesn't matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With