Class Generics


  • public class Generics
    extends Object
    Generics related utilities
    Author:
    igor.vaynberg
    • Method Detail

      • iterator

        public static <T> Iterator<T> iterator​(Iterator<?> delegate)
        Silences generics warning when need to cast iterator types
        Type Parameters:
        T -
        Parameters:
        delegate -
        Returns:
        delegate iterator cast to proper generics type
      • newHashMap

        public static <K,​V> HashMap<K,​V> newHashMap()
        Creates a new HashMap
        Type Parameters:
        K -
        V -
        Returns:
        new hash map
      • newHashMap

        public static <K,​V> HashMap<K,​V> newHashMap​(int capacity)
        Creates a new HashMap
        Type Parameters:
        K -
        V -
        Parameters:
        capacity - initial capacity
        Returns:
        new hash map
      • newArrayList

        public static <T> ArrayList<T> newArrayList​(int capacity)
        Creates a new ArrayList
        Type Parameters:
        T -
        Parameters:
        capacity - initial capacity
        Returns:
        array list
      • newArrayList

        public static <T> ArrayList<T> newArrayList()
        Creates a new ArrayList
        Type Parameters:
        T -
        Returns:
        array list
      • newConcurrentHashMap

        public static <K,​V> ConcurrentHashMap<K,​V> newConcurrentHashMap​(int initialCapacity)
        Creates a new ConcurrentHashMap
        Type Parameters:
        K -
        V -
        Parameters:
        initialCapacity - initial capacity
        Returns:
        new hash map