|
JType 0.1.1-redhat-2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.jtype.Generic<T>
T
- the type that this generic type literal representspublic abstract class Generic<T>
Provides a generic type literal.
This class captures the actual type argument used when subclassed. This allows it to be referenced as a type parameter at compile time and also makes it available at run time. It is intended to be used as follows:
Generic<List<String>> listStringType = new Generic<List<String>>()
{};
This allows generic type literals to be used in a simple manner as standard class literals. For example, consider the following generic method signature:
<T> void add(T element, Class<T> type)
A problem arises when <T>
is a generic type, such as List<String>
, since List<String>.class
produces a compile time error. Use of this class can mitigate this problem:
<T> void add(T element, Generic<T> type)
Which can then be invoked as follows:
add(new ArrayList<String>(), new Generic<List<String>>()
{});
Generics
,
Neal Gafter's blog: Super Type TokensConstructor Summary | |
---|---|
protected |
Generic()
|
Method Summary | ||
---|---|---|
boolean |
equals(Object object)
|
|
static
|
get(Class<T> klass)
|
|
static
|
get(Class<T> rawType,
Type... actualTypeArguments)
|
|
static Generic<?> |
get(Type type)
|
|
Class<? super T> |
getRawType()
|
|
Type |
getType()
|
|
int |
hashCode()
|
|
String |
toString()
|
|
String |
toUnqualifiedString()
|
|
static Generic<?> |
valueOf(String typeName)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Generic()
Method Detail |
---|
public Type getType()
public Class<? super T> getRawType()
public String toUnqualifiedString()
public static <T> Generic<T> get(Class<T> klass)
public static Generic<?> get(Type type)
public static <T> Generic<? extends T> get(Class<T> rawType, Type... actualTypeArguments)
public static Generic<?> valueOf(String typeName)
public int hashCode()
hashCode
in class Object
public boolean equals(Object object)
equals
in class Object
public String toString()
toString
in class Object
|
JType 0.1.1-redhat-2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |