Package org.jboss.weld.util.collections
Class WeldCollections
- java.lang.Object
-
- org.jboss.weld.util.collections.WeldCollections
-
public class WeldCollections extends Object
Collection utilities.- Author:
- Jozef Hartinger
-
-
Field Summary
Fields Modifier and Type Field Description static Map<Object,List<Object>>EMPTY_ARRAY_SET_MULTIMAP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> booleanaddAll(Collection<E> collection, E... elements)static <T> booleanaddIfNotNull(Collection<T> collection, T element)static <T> List<T>immutableGuavaList(List<T> list)Returns an immutable view of a given list.static <T> Set<T>immutableGuavaSet(Set<T> set)Returns an immutable view of a given set.static <T> List<T>immutableList(List<T> list)Returns an immutable view of a given list.static <K,V>
Map<K,V>immutableMap(Map<K,V> map)Returns an immutable view of a given map.static <T> Set<T>immutableSet(Set<T> set)Returns an immutable view of a given set.static <K,V>
VputIfAbsent(ConcurrentMap<K,V> map, K key, V value)Utility method for working with maps.static <T> List<T>sort(List<T> list, Comparator<? super T> comparator)Fluent version ofCollections.sort(List, Comparator)static StringtoMultiRowString(Collection<?> collection)Returns the supplied collection as a multi-row string with every toString() of every element of the collection in its own row.
-
-
-
Method Detail
-
immutableSet
public static <T> Set<T> immutableSet(Set<T> set)
Returns an immutable view of a given set. If the given set is empty, a shared instance is returned. If the given set is an instance ofArraySet, it is trimmed.
-
immutableGuavaSet
public static <T> Set<T> immutableGuavaSet(Set<T> set)
Returns an immutable view of a given set. If the given set is empty, a shared instance is returned.
-
immutableList
public static <T> List<T> immutableList(List<T> list)
Returns an immutable view of a given list. If the given list is empty, a shared instance is returned. If the given list is an instance ofArrayList, it is trimmed.
-
immutableGuavaList
public static <T> List<T> immutableGuavaList(List<T> list)
Returns an immutable view of a given list. If the given list is empty, a shared instance is returned.
-
immutableMap
public static <K,V> Map<K,V> immutableMap(Map<K,V> map)
Returns an immutable view of a given map. If the given map is empty, a shared instance is returned.
-
sort
public static <T> List<T> sort(List<T> list, Comparator<? super T> comparator)
Fluent version ofCollections.sort(List, Comparator)
-
toMultiRowString
public static String toMultiRowString(Collection<?> collection)
Returns the supplied collection as a multi-row string with every toString() of every element of the collection in its own row. Example: toMultiRowString(Arrays.asList("aaa", "bbb", "ccc")) will return:- aaa, - bbb, - ccc
-
addAll
public static <E> boolean addAll(Collection<E> collection, E... elements)
- Parameters:
collection-elements-- Returns:
- true if the collection changed as a result of the call
-
addIfNotNull
public static <T> boolean addIfNotNull(Collection<T> collection, T element)
-
putIfAbsent
public static <K,V> V putIfAbsent(ConcurrentMap<K,V> map, K key, V value)
Utility method for working with maps. UnlikeMap.putIfAbsent(Object, Object)this method always returns the value that ends up store in the map which is either the old value (if any was present) or the new value (if it was stored in the map).- Parameters:
map- the mapkey- the keyvalue- the value- Returns:
- the value that ends up store in the map which is either the old value (if any was present) or the new value (if it was stored in the map)
-
-