Class Generics


  • public class Generics
    extends java.lang.Object
    Generics related utilities
    Author:
    igor.vaynberg
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Iterator<T> iterator​(java.util.Iterator<?> delegate)
      Silences generics warning when need to cast iterator types
      static <T> java.util.ArrayList<T> newArrayList()
      Creates a new ArrayList
      static <T> java.util.ArrayList<T> newArrayList​(int capacity)
      Creates a new ArrayList
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      newConcurrentHashMap()
      Creates a new ConcurrentHashMap
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      newConcurrentHashMap​(int initialCapacity)
      Creates a new ConcurrentHashMap
      static <K,​V>
      java.util.HashMap<K,​V>
      newHashMap()
      Creates a new HashMap
      static <K,​V>
      java.util.HashMap<K,​V>
      newHashMap​(int capacity)
      Creates a new HashMap
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • iterator

        public static <T> java.util.Iterator<T> iterator​(java.util.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> java.util.HashMap<K,​V> newHashMap()
        Creates a new HashMap
        Type Parameters:
        K -
        V -
        Returns:
        new hash map
      • newHashMap

        public static <K,​V> java.util.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> java.util.ArrayList<T> newArrayList​(int capacity)
        Creates a new ArrayList
        Type Parameters:
        T -
        Parameters:
        capacity - initial capacity
        Returns:
        array list
      • newArrayList

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

        public static <K,​V> java.util.concurrent.ConcurrentHashMap<K,​V> newConcurrentHashMap()
        Creates a new ConcurrentHashMap
        Type Parameters:
        K -
        V -
        Returns:
        new hash map
      • newConcurrentHashMap

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