Package org.apache.dubbo.common.utils
Class CollectionUtils
java.lang.Object
org.apache.dubbo.common.utils.CollectionUtils
Miscellaneous collection utility methods.
Mainly for internal use within the framework.
- Since:
- 2.0.7
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> intaddAll(Collection<T> collection, T... values) Add the multiple values intothe specified collectionstatic intcapacity(int expectedSize) static booleanequals(Collection<?> one, Collection<?> another) Compares the specified collection with another, the main implementation referencesAbstractSetstatic <T> Tfirst(Collection<T> values) Take the first element from the specified collectionstatic <T> Tstatic <K,V> Map <V, K> Flip the specifiedMapstatic booleanisEmpty(Collection<?> collection) Returntrueif the supplied Collection isnullor empty.static booleanisEmptyMap(Map map) Returntrueif the supplied Map isnullor empty.static booleanisNotEmpty(Collection<?> collection) Returntrueif the supplied Collection isnot nullor not empty.static booleanisNotEmptyMap(Map map) Returntrueif the supplied Map isnot nullor not empty.static Stringstatic booleanstatic <K,T> Map <K, T> static <K,T> Map <K, T> newConcurrentHashMap(int expectedSize) static <K,T> Map <K, T> newHashMap(int expectedSize) static <T> Set<T> newHashSet(int expectedSize) static <K,T> Map <K, T> newLinkedHashMap(int expectedSize) static <T> Set<T> newLinkedHashSet(int expectedSize) static <K,V> Map <K, V> static <T> Set<T> ofSet(T... values) Convert to multiple values to beLinkedHashSetstatic intsize(Collection<?> collection) Get the size of the specifiedCollectionstatic <T> List<T> sortSimpleName(List<String> list) static <K,V> Map <K, V> toStringMap(String... pairs) static <T> Set<T>
-
Method Details
-
sort
-
sortSimpleName
-
flip
Flip the specifiedMap -
splitAll
-
joinAll
-
split
-
join
-
join
-
mapEquals
-
toStringMap
-
toMap
-
objToMap
- Throws:
IllegalAccessException
-
isEmpty
Returntrueif the supplied Collection isnullor empty. Otherwise, returnfalse.- Parameters:
collection- the Collection to check- Returns:
- whether the given Collection is empty
-
isNotEmpty
Returntrueif the supplied Collection isnot nullor not empty. Otherwise, returnfalse.- Parameters:
collection- the Collection to check- Returns:
- whether the given Collection is not empty
-
isEmptyMap
Returntrueif the supplied Map isnullor empty. Otherwise, returnfalse.- Parameters:
map- the Map to check- Returns:
- whether the given Map is empty
-
isNotEmptyMap
Returntrueif the supplied Map isnot nullor not empty. Otherwise, returnfalse.- Parameters:
map- the Map to check- Returns:
- whether the given Map is not empty
-
ofSet
Convert to multiple values to beLinkedHashSet- Type Parameters:
T- the type ofvalues- Parameters:
values- one or more values- Returns:
- read-only
Set
-
size
Get the size of the specifiedCollection- Parameters:
collection- the specifiedCollection- Returns:
- must be positive number
- Since:
- 2.7.6
-
equals
Compares the specified collection with another, the main implementation referencesAbstractSet- Parameters:
one-Collectionanother-Collection- Returns:
- if equals, return
true, orfalse - Since:
- 2.7.6
-
addAll
Add the multiple values intothe specified collection- Type Parameters:
T- the type of values- Parameters:
collection-the specified collectionvalues- the multiple values- Returns:
- the effected count after added
- Since:
- 2.7.6
-
first
Take the first element from the specified collection- Type Parameters:
T- the type of element of collection- Parameters:
values- the collection object- Returns:
- if found, return the first one, or
null - Since:
- 2.7.6
-
first
-
toTreeSet
-
newHashSet
-
newLinkedHashSet
-
newHashMap
-
newLinkedHashMap
-
newConcurrentHashMap
-
newConcurrentHashMap
-
capacity
public static int capacity(int expectedSize)
-