public abstract class CollectionUtils extends CollectionUtils
Collection
,
Collections
,
Enumeration
,
Iterator
,
List
,
Map
,
Set
,
CollectionUtils
Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
asSet(T... elements)
Returns an unmodifiable
Set containing the elements from the given object array. |
static <T> Iterable<T> |
iterable(Enumeration<T> enumeration)
Adapts the given Enumeration as an Iterable object for use within a for each loop.
|
static <T> Iterable<T> |
iterable(Iterator<T> iterator)
Adapts the given Iterator as an Iterable object for use within a for each loop.
|
static <T> Collection<T> |
nullSafeCollection(Collection<T> collection)
A null-safe operation returning the original Collection if non-null or an empty Collection
(implemented with List) if null.
|
static <T> Iterable<T> |
nullSafeIterable(Iterable<T> iterable)
A null-safe operation returning the original Iterable object if non-null or a default, empty Iterable
implementation if null.
|
static <T> List<T> |
nullSafeList(List<T> list)
|
static <K,V> Map<K,V> |
nullSafeMap(Map<K,V> map)
|
static <T> Set<T> |
nullSafeSet(Set<T> set)
|
static <T extends Comparable<T>> |
sort(List<T> list)
Sors the elements of the given
List by their natural, Comparable ordering. |
static <T> List<T> |
subList(List<T> source,
int... indices)
Returns a sub-list of elements from the given
List based on the provided indices . |
arrayToList, contains, contains, containsAny, containsInstance, findCommonElementType, findFirstMatch, findValueOfType, findValueOfType, hasUniqueObject, isEmpty, isEmpty, mergeArrayIntoCollection, mergePropertiesIntoMap, toArray, toIterator, toMultiValueMap, unmodifiableMultiValueMap
public static <T> Set<T> asSet(T... elements)
Set
containing the elements from the given object array.public static <T> Iterable<T> iterable(Enumeration<T> enumeration)
T
- the class type of the Enumeration elements.enumeration
- the Enumeration to adapt as an Iterable object.Iterable
,
Enumeration
public static <T> Iterable<T> iterable(Iterator<T> iterator)
public static <T> Collection<T> nullSafeCollection(Collection<T> collection)
T
- the element class type of the Collection.collection
- the Collection to evaluate for being null.Collections.emptyList()
,
Collection
public static <T> Iterable<T> nullSafeIterable(Iterable<T> iterable)
public static <T extends Comparable<T>> List<T> sort(List<T> list)
List
by their natural, Comparable
ordering.T
- Comparable
class type of the collection elements.list
- List
of elements to sort.List
sorted.Collections.sort(List)
,
List
public static <T> List<T> subList(List<T> source, int... indices)
List
based on the provided indices
.T
- Class type of the elements in the list.source
- List
from which the elements of the sub-list is constructed.indices
- array of indexes in the source
List
to the elements
used to construct the sub-list.List
based on the provided indices
.IndexOutOfBoundsException
- if the array of indexes contains an index that is not within
the bounds of the list.NullPointerException
- if either the list or indexes are null.List
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.