Class ReifiedType
Java 5 and later support generic types. These types consist of a raw class
with type parameters. This class models such a Type
class but ensures
that the type is reified. Reification means that the Type graph
associated with a Java 5 Type
instance is traversed until the type
becomes a concrete class. This class is available with the
getRawClass()
method. The optional type parameters are recursively
represented as Reified Types.
In Java 1.4, a class has by definition no type parameters. This class
implementation provides the Reified Type for Java 1.4 by making the raw class
the Java 1.4 class and using a Reified Type based on the Object
class
for any requested type parameter.
A Blueprint extender implementations can subclass this class and provide
access to the generic type parameter graph for conversion. Such a subclass
must reify the different Java 5 Type
instances into the
reified form. That is, a form where the raw Class is available with its
optional type parameters as Reified Types.
- Author:
- $Id: 0e2e040d652f98008e853cd6b1642626a3ec05c1 $
-
Constructor Summary
ConstructorsConstructorDescriptionReifiedType
(Class<?> clazz) Create a Reified Type for a raw Java class without any generic type parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetActualTypeArgument
(int i) Return a type parameter for this type.Class
<?> Return the raw class represented by this type.int
size()
Return the number of type parameters for this type.
-
Constructor Details
-
ReifiedType
Create a Reified Type for a raw Java class without any generic type parameters. Subclasses can provide the optional generic type parameter information. Without subclassing, this instance has no type parameters.- Parameters:
clazz
- The raw class of the Reified Type.
-
-
Method Details
-
getRawClass
Return the raw class represented by this type. The raw class represents the concrete class that is associated with a type declaration. This class could have been deduced from the generics type parameter graph of the declaration. For example, in the following example:Map<String, ? extends Metadata>
The raw class is the Map class.- Returns:
- The raw class represented by this type.
-
getActualTypeArgument
Return a type parameter for this type. The type parameter refers to a parameter in a generic type declaration given by the zero-based indexi
. For example, in the following example:Map<String, ? extends Metadata>
type parameter 0 isString
, and type parameter 1 isMetadata
.This implementation returns a Reified Type that has
Object
as class. Any object is assignable to Object and therefore no conversion is then necessary. This is compatible with versions of Java language prior to Java 5. This method should be overridden by a subclass that provides access to the generic type parameter information for Java 5 and later.- Parameters:
i
- The zero-based index of the requested type parameter.- Returns:
- The
ReifiedType
for the generic type parameter at the specified index.
-
size
public int size()Return the number of type parameters for this type.This implementation returns
0
. This method should be overridden by a subclass that provides access to the generic type parameter information for Java 5 and later.- Returns:
- The number of type parameters for this type.
-