edu.stanford.nlp.util
Class ErasureUtils

java.lang.Object
  extended by edu.stanford.nlp.util.ErasureUtils

public class ErasureUtils
extends Object

Class to gather unsafe operations into one place.

Author:
dlwh

Method Summary
static
<T> T[][]
mkT2DArray(Class<?> klass, int[] dim)
           
static
<T> T[]
mkTArray(Class<?> klass, int size)
          Makes an array based on klass, but casts it to be of type T[].
static void noop(Object o)
          Does nothing, occasionally used to make Java happy that a value is used
static
<T> List<T>
sortedIfPossible(Collection<T> collection)
           
static
<T> T
uncheckedCast(Object o)
          Casts an Object to a T
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

uncheckedCast

public static <T> T uncheckedCast(Object o)
Casts an Object to a T

Type Parameters:
T -

noop

public static void noop(Object o)
Does nothing, occasionally used to make Java happy that a value is used


mkTArray

public static <T> T[] mkTArray(Class<?> klass,
                               int size)
Makes an array based on klass, but casts it to be of type T[]. This is a very unsafe operation and should be used carefully. Namely, you should ensure that klass is a subtype of T, or that klass is a supertype of T *and* that the array will not escape the generic constant *and* that klass is the same as the erasure of T.

Type Parameters:
T -

mkT2DArray

public static <T> T[][] mkT2DArray(Class<?> klass,
                                   int[] dim)

sortedIfPossible

public static <T> List<T> sortedIfPossible(Collection<T> collection)


Stanford NLP Group