public final class CollectionHelper extends Object
Modifier | Constructor and Description |
---|---|
private |
CollectionHelper() |
Modifier and Type | Method and Description |
---|---|
static <K,V> void |
addToCollectionMap(K key,
V valueToAdd,
Map<K,Collection<V>> map)
Add a value to a map collection, initializing the key's collection if needed
|
static <T> List<T> |
asList(Iterable<? extends T> iterable)
Deprecated.
use
Lists.newArrayList(java.lang.Iterable) |
static <T> List<T> |
asList(T t,
T... ts)
Deprecated.
|
static <T> Set<T> |
asSet(Iterable<? extends T> iterable)
Deprecated.
use
Sets.newHashSet(java.lang.Iterable) |
static <T> Set<T> |
asSet(T t,
T... ts)
Deprecated.
|
static <T> Collection<T> |
collection()
Deprecated.
use
Lists.newLinkedList() or
Lists.newArrayList() . |
static <T> Collection<T> |
collection(T... elements)
Deprecated.
use
Lists.newArrayList() . |
static String |
collectionToString(Collection<?> collection) |
static <T> List<T> |
conjunctCollections(Collection<T> list1,
Collection<T> list2) |
static <T> Set<T> |
conjunctCollectionsToSet(Collection<T> list1,
Collection<T> list2) |
static <T> boolean |
isEmpty(Collection<T> collection)
Check if collection is not null and empty
|
static <K,V> boolean |
isEmpty(Map<K,V> map)
Check if map is not null and empty
|
static <T> boolean |
isNotEmpty(Collection<T> collection)
Check if collection is not null and not empty
|
static <K,V> boolean |
isNotEmpty(Map<K,V> map)
Check if collection is not null and not empty
|
static boolean |
isNotNullOrEmpty(Object[] array)
Check if array is not null and not empty
|
static boolean |
isNullOrEmpty(Object[] array)
Check if array is not null or not empty
|
static <T> List<T> |
list()
Deprecated.
use
Lists.newLinkedList() or
Lists.newArrayList() . |
static <T> List<T> |
list(T... elements) |
static <K,V> Map<K,V> |
map()
Deprecated.
use
Maps.newHashMap() |
static <K,V> Map<K,V> |
map(Map.Entry<K,V>... entries) |
static boolean |
nullEmptyOrContainsOnlyNulls(Collection<? extends Object> collection)
Examine a collection and determines if it is null, empty, or contains
only null values
|
static <K,V> Map<V,K> |
reverse(Map<K,V> map)
Reverses a map (switches key and value types).
|
static <T> Set<T> |
set()
Deprecated.
use
Sets.newHashSet() |
static <T> Set<T> |
set(T... elements)
Deprecated.
use
Sets.newHashSet(Object...) |
static <K,V extends Comparable<? super V>> |
sortByValue(Map<K,V> map) |
static <K,V> Map<K,V> |
synchronizedInitialSizeMapWithLoadFactor1(int capacity) |
static <E> List<E> |
synchronizedList()
Constructs a new synchronized
List based on a LinkedList . |
static <E> List<E> |
synchronizedList(int initialCapacity)
|
static <K,V> Map<K,V> |
synchronizedMap() |
static <K,V> Map<K,V> |
synchronizedMap(int initialCapacity) |
static <K,V> Map<K,V> |
synchronizedMap(int initialCapacity,
float loadFactor) |
static <T> Set<T> |
synchronizedSet()
Constructs a new synchronized
Set based on a HashSet . |
static <T> Set<T> |
synchronizedSet(int initialCapacity)
|
static <T> Set<T> |
union(Iterable<Set<T>> elements) |
static <T> Set<T> |
union(Set<T>... elements) |
static <T> Set<T> |
unionOfListOfLists(Collection<? extends Collection<T>> collectionOfCollection) |
static <T> Collection<T> |
unmodifiableCollection(Collection<? extends T> c) |
static <T> List<T> |
unmodifiableList(List<? extends T> l) |
static <K,V> Map<K,V> |
unmodifiableMap(Map<? extends K,? extends V> m) |
static <T> Set<T> |
unmodifiableSet(Set<? extends T> s) |
@Deprecated public static <T> Set<T> set(T... elements)
Sets.newHashSet(Object...)
@Deprecated public static <T> Set<T> set()
Sets.newHashSet()
public static <K,V> Map<K,V> map(Map.Entry<K,V>... entries)
entries
- the final set of entries to add to the newly created
unmodifiable map@Deprecated public static <K,V> Map<K,V> map()
Maps.newHashMap()
@Deprecated public static <T> List<T> list()
Lists.newLinkedList()
or
Lists.newArrayList()
.@Deprecated public static <T> Collection<T> collection()
Lists.newLinkedList()
or
Lists.newArrayList()
.@Deprecated public static <T> Collection<T> collection(T... elements)
Lists.newArrayList()
.public static <T> List<T> list(T... elements)
@Deprecated public static <T> Set<T> asSet(Iterable<? extends T> iterable)
Sets.newHashSet(java.lang.Iterable)
@Deprecated public static <T> List<T> asList(Iterable<? extends T> iterable)
Lists.newArrayList(java.lang.Iterable)
public static <T> Set<T> unmodifiableSet(Set<? extends T> s)
public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> m)
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c)
public static <T> List<T> unmodifiableList(List<? extends T> l)
@Deprecated public static <T> List<T> asList(T t, T... ts)
@Deprecated public static <T> Set<T> asSet(T t, T... ts)
public static <T> List<T> conjunctCollections(Collection<T> list1, Collection<T> list2)
public static <T> Set<T> conjunctCollectionsToSet(Collection<T> list1, Collection<T> list2)
public static <K,V> Map<K,V> synchronizedInitialSizeMapWithLoadFactor1(int capacity)
public static <K,V> Map<K,V> synchronizedMap()
public static <K,V> Map<K,V> synchronizedMap(int initialCapacity)
public static <K,V> Map<K,V> synchronizedMap(int initialCapacity, float loadFactor)
public static <T> Set<T> synchronizedSet()
Set
based on a HashSet
.public static <T> Set<T> synchronizedSet(int initialCapacity)
initialCapacity
- the initial capacity of the setpublic static <E> List<E> synchronizedList()
List
based on a LinkedList
.public static <E> List<E> synchronizedList(int initialCapacity)
initialCapacity
- the initial capacity of the array listpublic static <T> Set<T> unionOfListOfLists(Collection<? extends Collection<T>> collectionOfCollection)
collectionOfCollection
- a Collection<Collection<T>>public static <T> boolean isNotEmpty(Collection<T> collection)
collection
- Collection to checkpublic static <T> boolean isEmpty(Collection<T> collection)
collection
- Collection to checkpublic static <K,V> boolean isNotEmpty(Map<K,V> map)
map
- Map to checkpublic static <K,V> boolean isEmpty(Map<K,V> map)
map
- map to checkpublic static <K,V> Map<V,K> reverse(Map<K,V> map)
K
- the key typeV
- the value typemap
- the mappublic static boolean nullEmptyOrContainsOnlyNulls(Collection<? extends Object> collection)
collection
- Collection to examinepublic static boolean isNotNullOrEmpty(Object[] array)
array
- Array to checktrue
, if array is not null and not emptypublic static boolean isNullOrEmpty(Object[] array)
array
- Array to checktrue
, if array is null or emptypublic static String collectionToString(Collection<?> collection)
public static <K,V> void addToCollectionMap(K key, V valueToAdd, Map<K,Collection<V>> map)
key
- Key whose value collection should be added tovalueToAdd
- Vale to add to the key's collectionmap
- Map holding collectionspublic static <K,V extends Comparable<? super V>> Map<K,V> sortByValue(Map<K,V> map)
Copyright © 2012-2015 52north.org. All Rights Reserved.