Class WeldCollections

java.lang.Object
org.jboss.weld.util.collections.WeldCollections

public class WeldCollections extends Object
Collection utilities.
Author:
Jozef Hartinger
  • Method Details

    • immutableSetView

      public static <T> Set<T> immutableSetView(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 of ArraySet, it is trimmed.
    • immutableListView

      public static <T> List<T> immutableListView(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 of ArrayList, it is trimmed.
    • immutableMapView

      public static <K, V> Map<K,V> immutableMapView(Map<K,V> map)
      Returns an immutable view of a given map.
    • sort

      public static <T> List<T> sort(List<T> list, Comparator<? super T> 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
       
    • addIfNotNull

      public static <T> boolean addIfNotNull(Collection<T> collection, T element)
    • putIfAbsent

      public static <K, V> V putIfAbsent(Map<K,V> map, K key, V value)
      Utility method for working with maps. Unlike Map.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 map
      key - the key
      value - 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)