nl.knowledgeplaza.util
Class TypeRef<T>

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

public abstract class TypeRef<T>
extends java.lang.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 java.lang.Class getClass(java.lang.reflect.Type t)
          Get class
static java.lang.Class getClass(TypeRef t)
           
static java.util.List<java.lang.reflect.Type> getEmbeddedTypes(java.lang.reflect.Type t)
          Get embedded types
static java.util.List<java.lang.reflect.Type> getEmbeddedTypes(TypeRef t)
           
 java.lang.reflect.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 java.lang.NoSuchMethodException,
                     java.lang.IllegalAccessException,
                     java.lang.reflect.InvocationTargetException,
                     java.lang.InstantiationException
Instantiates a new instance of T using the default, no-arg constructor.

Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException

getType

public java.lang.reflect.Type getType()
Gets the referenced type.


getClass

public static java.lang.Class getClass(java.lang.reflect.Type t)
Get class

Parameters:
indent -
t -

getClass

public static java.lang.Class getClass(TypeRef t)

getEmbeddedTypes

public static java.util.List<java.lang.reflect.Type> getEmbeddedTypes(java.lang.reflect.Type t)
Get embedded types

Parameters:
indent -
t -

getEmbeddedTypes

public static java.util.List<java.lang.reflect.Type> getEmbeddedTypes(TypeRef t)


Copyright © 2010 KnowledgePlaza. All Rights Reserved.