Class CollectionUtils
- java.lang.Object
-
- com.alibaba.nacos.client.naming.utils.CollectionUtils
-
public class CollectionUtils extends Object
Provides utility methods and decorators forCollectioninstances.- Since:
- Commons Collections 1.0
- Version:
- $Revision: 1713167 $ $Date: 2015-11-07 20:44:03 +0100 (Sat, 07 Nov 2015) $
- Author:
- Rodney Waldhoff, Paul Jack, Stephen Colebourne, Steve Downey, Herve Quiroz, Peter KoBek, Matthew Hawthorne, Janek Bogucki, Phil Steitz, Steven Melzer, Jon Schewe, Neil O'Toole, Stephen Smith
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()CollectionUtilsshould not normally be instantiated.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MapgetCardinalityMap(Collection coll)Returns aMapmapping each unique element in the givenCollectionto anIntegerrepresenting the number of occurrences of that element in theCollection.static booleanisEmpty(Collection coll)Null-safe check if the specified collection is empty.static booleanisEqualCollection(Collection a, Collection b)Returns true iff the givenCollections contain exactly the same elements with exactly the same cardinalities.static Collectionsubtract(Collection a, Collection b)Returns a newCollectioncontaining a - b.
-
-
-
Method Detail
-
subtract
public static Collection subtract(Collection a, Collection b)
Returns a newCollectioncontaining a - b. The cardinality of each element e in the returnedCollectionwill be the cardinality of e in a minus the cardinality of e in b, or zero, whichever is greater.- Parameters:
a- the collection to subtract from, must not be nullb- the collection to subtract, must not be null- Returns:
- a new collection with the results
- See Also:
Collection.removeAll(java.util.Collection<?>)
-
getCardinalityMap
public static Map getCardinalityMap(Collection coll)
Returns aMapmapping each unique element in the givenCollectionto anIntegerrepresenting the number of occurrences of that element in theCollection.Only those elements present in the collection will appear as keys in the map.
- Parameters:
coll- the collection to get the cardinality map for, must not be null- Returns:
- the populated cardinality map
-
isEqualCollection
public static boolean isEqualCollection(Collection a, Collection b)
Returns true iff the givenCollections contain exactly the same elements with exactly the same cardinalities.That is, iff the cardinality of e in a is equal to the cardinality of e in b, for each element e in a or b.
- Parameters:
a- the first collection, must not be nullb- the second collection, must not be null- Returns:
trueiff the collections contain the same elements with the same cardinalities.
-
isEmpty
public static boolean isEmpty(Collection coll)
Null-safe check if the specified collection is empty.Null returns true.
- Parameters:
coll- the collection to check, may be null- Returns:
- true if empty or null
- Since:
- Commons Collections 3.2
-
-