Class CollectionHelper


  • public final class CollectionHelper
    extends Object
    Provides some methods for simplified collection instantiation.
    Author:
    Gunnar Morling, Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI, Hardy Ferentschik, Guillaume Smet
    • Method Detail

      • newHashMap

        public static <K,​V> HashMap<K,​V> newHashMap()
      • newHashMap

        public static <K,​V> HashMap<K,​V> newHashMap​(int size)
      • newHashMap

        public static <K,​V> HashMap<K,​V> newHashMap​(Map<K,​V> map)
      • newConcurrentHashMap

        public static <K,​V> ConcurrentHashMap<K,​V> newConcurrentHashMap()
      • newHashSet

        public static <T> HashSet<T> newHashSet()
      • newHashSet

        public static <T> HashSet<T> newHashSet​(int size)
      • newHashSet

        public static <T> HashSet<T> newHashSet​(Collection<? extends T> c)
      • newHashSet

        public static <T> HashSet<T> newHashSet​(Iterable<? extends T> iterable)
      • newLinkedHashSet

        public static <T> LinkedHashSet<T> newLinkedHashSet()
      • newArrayList

        public static <T> ArrayList<T> newArrayList()
      • newArrayList

        public static <T> ArrayList<T> newArrayList​(int size)
      • toImmutableList

        public static <T> List<T> toImmutableList​(List<? extends T> list)
      • toImmutableSet

        public static <T> Set<T> toImmutableSet​(Set<? extends T> set)
      • toImmutableMap

        public static <K,​V> Map<K,​V> toImmutableMap​(Map<K,​V> map)
      • iteratorFromArray

        public static Iterator<?> iteratorFromArray​(Object object)
        Builds an Iterator for a given array. It is (un)necessarily ugly because we have to deal with array of primitives.
        Parameters:
        object - a given array
        Returns:
        an Iterator iterating over the array
      • iterableFromArray

        public static Iterable<?> iterableFromArray​(Object object)
        Builds an Iterable for a given array. It is (un)necessarily ugly because we have to deal with array of primitives.
        Parameters:
        object - a given array
        Returns:
        an Iterable providing iterators over the array