nl.knowledgeplaza.util
Class TypeRef<T>

java.lang.Object
  extended by nl.knowledgeplaza.util.TypeRef<T>

public abstract class TypeRef<T>
extends Object

References a generic type. http://gafter.blogspot.com/2006/12/super-type-tokens.html Instead of: List.class use: TypeRef< List > x = new TypeRef< List >(){}; Or type safe instantiation: List l1 = new TypeRef< ArrayList >(){}.newInstance(); List l2 = new TypeRef< ArrayList >(){}.newInstance();


Constructor Summary
protected TypeRef()
           
 
Method Summary
static Class getClass(Type t)
          Get class
static Class getClass(TypeRef t)
           
static List<Type> getEmbeddedTypes(Type t)
          Get embedded types
static List<Type> getEmbeddedTypes(TypeRef t)
           
 Type getType()
          Gets the referenced type.
 T newInstance()
          Instantiates a new instance of T using the default, no-arg constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeRef

protected TypeRef()
Method Detail

newInstance

public T newInstance()
              throws NoSuchMethodException,
                     IllegalAccessException,
                     InvocationTargetException,
                     InstantiationException
Instantiates a new instance of T using the default, no-arg constructor.

Throws:
NoSuchMethodException
IllegalAccessException
InvocationTargetException
InstantiationException

getType

public Type getType()
Gets the referenced type.


getClass

public static Class getClass(Type t)
Get class

Parameters:
indent -
t -

getClass

public static Class getClass(TypeRef t)

getEmbeddedTypes

public static List<Type> getEmbeddedTypes(Type t)
Get embedded types

Parameters:
indent -
t -

getEmbeddedTypes

public static List<Type> getEmbeddedTypes(TypeRef t)


Copyright © 2012 KnowledgePlaza. All Rights Reserved.