public class GType extends Object implements ParameterizedType
Description for terms usage. Be it a generic class definition and a reference, see sample codes. On definition,
Box
is the class name; in GType class context it is name rawType
. The type parameter section, delimited
by angle brackets, follows the class name. It specifies the type parameters (also called type variables), in this case T.
Type parameters are not represented by GType class.
class Box<T> { private T t; }
To reference the generic Box class from within your code, you must perform a generic type invocation, which replaces T with some concrete value, such as Integer:
Box<Integer> integers = new Box<Integer>();
The list of type arguments used to reference a generic type is named actualTypeArguments
into GType class. Note that
a generic type reference, in which type parameters/variables are replaced by concrete type is named
parameterized type.
Modifier and Type | Field and Description |
---|---|
private Type[] |
actualTypeArguments
Actual type arguments used to reference parameterized type.
|
private Type |
rawType
Class or interface declaring this parameterized type.
|
private String |
string
Cached string representation for this GType instance.
|
Constructor and Description |
---|
GType(Type rawType,
Type... actualTypeArguments)
Construct immutable parameterized type instance.
|
Modifier and Type | Method and Description |
---|---|
Type[] |
getActualTypeArguments()
Returns an array of Type objects representing the actual type arguments to this type.
|
Type |
getOwnerType()
Always returns null since GType is top level class, that is, is not declared as inner class.
|
Type |
getRawType()
Returns the Type object representing the class or interface that declared this type.
|
String |
toString()
String representation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTypeName
private final Type rawType
Map<String, Integer>
this field
contains java.util.Map
.private final Type[] actualTypeArguments
Map<String, Integer>
this
field contains java.lang.String
and java.lang.Integer
.private String string
public Type[] getActualTypeArguments()
Note that in some cases, the returned array be empty. This can occur if this type represents a non-parameterized type nested within a parameterized type.
getActualTypeArguments
in interface ParameterizedType
actualTypeArguments
public Type getOwnerType()
getOwnerType
in interface ParameterizedType
public Type getRawType()
getRawType
in interface ParameterizedType
rawType
Copyright © 2018. All rights reserved.