nl.knowledgeplaza.util
Class TypeRef<T>
java.lang.Object
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()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TypeRef
protected TypeRef()
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 © 2011 KnowledgePlaza. All Rights Reserved.