java.lang.reflect

Interface TypeVariable<T>

public interface TypeVariable<T extends GenericDeclaration> extends Type

This is a common interface for all type variables provided by the Java language. Instances are created the first time a type variable is needed by one of the reflective methods declared in this package.

Creating a type variable requires resolving the appropriate type. This may involve resolving other classes as a side effect (e.g. if the type is nested inside other classes). Creation should not involve resolving the bounds. Repeated creation has no effect; an equivalent instance is returned. Caching is not required, but all instances must be equal() to each other.

Since: 1.5

Method Summary
Type[]getBounds()
Returns an array of Type objects which represent the upper bounds of this type variable.
TgetGenericDeclaration()
Returns a representation of the declaration used to declare this type variable.
StringgetName()
Returns the name of the type variable, as written in the source code.

Method Detail

getBounds

public Type[] getBounds()
Returns an array of Type objects which represent the upper bounds of this type variable. There is always a default bound of Object. Any ParameterizedTypes will be created as necessary, and other types resolved.

Returns: an array of Type objects representing the upper bounds.

Throws: TypeNotPresentException if any of the bounds refer to a non-existant type. MalformedParameterizedTypeException if the creation of a ParameterizedType fails.

getGenericDeclaration

public T getGenericDeclaration()
Returns a representation of the declaration used to declare this type variable.

Returns: the GenericDeclaration object for this type variable.

getName

public String getName()
Returns the name of the type variable, as written in the source code.

Returns: the name of the type variable.