Package org.jboss.weld.util.collections
Class WeldCollections
java.lang.Object
org.jboss.weld.util.collections.WeldCollections
Collection utilities.
- Author:
- Jozef Hartinger
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleanaddIfNotNull(Collection<T> collection, T element) static <T> List<T>immutableListView(List<T> list) Returns an immutable view of a given list.static <K,V> Map<K, V> immutableMapView(Map<K, V> map) Returns an immutable view of a given map.static <T> Set<T>immutableSetView(Set<T> set) Returns an immutable view of a given set.static <K,V> V putIfAbsent(Map<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 Details
-
immutableSetView
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. -
immutableListView
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. -
immutableMapView
Returns an immutable view of a given map. -
sort
Fluent version ofCollections.sort(List, Comparator) -
toMultiRowString
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
-
addIfNotNull
-
putIfAbsent
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)
-