nl.knowledgeplaza.util
Class GenericsUtil

java.lang.Object
  extended by nl.knowledgeplaza.util.GenericsUtil

public class GenericsUtil
extends Object

Constructors for easy generics: Map> m = newHashMap(); instead of: Map> m = new HashMap>(); This is also available Google Collections in http://code.google.com/p/google-collections/ Which will be moved to Guava sometime http://code.google.com/p/guava-libraries/

Author:
toeu

Constructor Summary
GenericsUtil()
           
 
Method Summary
static
<E> ArrayList<E>
newArrayList()
           
static
<E> AtomicReference<E>
newAtomicReference()
           
static
<T> T[]
newEmptyArray(Class<T> type)
          Keeping a cache of empty arrays can greatly improve performance.
static
<K,V> HashMap<K,V>
newHashMap()
           
static
<K,V> Hashtable<K,V>
newHashtable()
           
static
<K,V> LinearMap<K,V>
newLinearMap()
           
static
<E> LinkedList<E>
newLinkedList()
           
static
<T> SoftReference<T>
newSoftReference(T t)
           
static
<K,V> TreeMap<K,V>
newTreeMap()
           
static
<E> Vector<E>
newVector()
           
static
<K,V> WeakHashMap<K,V>
newWeakHashMap()
           
static
<T> WeakReference<T>
newWeakReference(T t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericsUtil

public GenericsUtil()
Method Detail

newHashMap

public static <K,V> HashMap<K,V> newHashMap()
Type Parameters:
K -
V -
Returns:

newLinearMap

public static <K,V> LinearMap<K,V> newLinearMap()
Type Parameters:
K -
V -
Returns:

newWeakHashMap

public static <K,V> WeakHashMap<K,V> newWeakHashMap()
Type Parameters:
K -
V -
Returns:

newTreeMap

public static <K,V> TreeMap<K,V> newTreeMap()
Type Parameters:
K -
V -
Returns:

newHashtable

public static <K,V> Hashtable<K,V> newHashtable()
Type Parameters:
K -
V -
Returns:

newArrayList

public static <E> ArrayList<E> newArrayList()
Type Parameters:
E -
Returns:

newLinkedList

public static <E> LinkedList<E> newLinkedList()
Type Parameters:
E -
Returns:

newVector

public static <E> Vector<E> newVector()
Type Parameters:
E -
Returns:

newWeakReference

public static <T> WeakReference<T> newWeakReference(T t)
Type Parameters:
T -
Parameters:
t -
Returns:

newSoftReference

public static <T> SoftReference<T> newSoftReference(T t)
Type Parameters:
T -
Parameters:
t -
Returns:

newAtomicReference

public static <E> AtomicReference<E> newAtomicReference()
Type Parameters:
E -
Returns:

newEmptyArray

public static <T> T[] newEmptyArray(Class<T> type)
Keeping a cache of empty arrays can greatly improve performance. This is a generics version.



Copyright © 2012 KnowledgePlaza. All Rights Reserved.