T.
Supports in-line instantiation of objects that represent generic types with
actual type parameters. An object that represents any parameterized type may
be obtained by sub-classing GenericType. Alternatively, an object
representing a concrete parameterized type can be created using a
GenericType(java.lang.reflect.Type) and manually specifying
the actual (parameterized) type.
For example:
GenericType<List<String>> stringListType = new GenericType<List<String>>() {};
Or:
public class MyGenericType extends GenericType<List<String>> { ... }
...
MyGenericType stringListType = new MyGenericType();
Note that due to the Java type erasure limitations the parameterized type information
must be specified on a subclass, not just during the instance creation. For example,
the following case would throw an IllegalArgumentException:
public class MyGenericType<T> extends GenericType<T> { ... }
...
// The type is only specified on instance, not in a sub-class
MyGenericType<List<String>> stringListType =
new MyGenericType<List<String>>();
| Modifier and Type | Field and Description |
|---|---|
| private final Class | rawType
The actual raw parameter type. |
| private final Type | type
Type represented by the generic type instance. |
| Access | Constructor and Description |
|---|---|
| protected | GenericType()
Constructs a new generic type, deriving the generic type and class from type parameter. |
| public | GenericType(Type
the generic type. genericType)Constructs a new generic type, supplying the generic type information and deriving the class. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| public static GenericType | Returns: GenericType describing the Java instance.Java instance for which the instance)GenericType description should be created.Create a |
| private static Class | Returns: the array class.the component class of the array c)Get Array class of component class. |
| private static Class | |
| public final Class | Returns: the class or interface that declared the type represented by this generic type instance.Returns the object representing the class or interface that declared the type represented by this generic type instance. |
| public final Type | Returns: the actual type represented by this generic type instance.Retrieve the type represented by the generic type instance. |
| pack-priv static Type | Returns: the parameterized type ofGenericType<T> (aka T)subClass of clazz, Class<?> baseClass to analyze.base class having the type parameter the value of which we need to retrieve baseClass)Return the value of the type parameter of |
| public int | |
| public String |
| rawType | back to summary |
|---|---|
| private final Class<?> rawType The actual raw parameter type. | |
| type | back to summary |
|---|---|
| private final Type type Type represented by the generic type instance. | |
| GenericType | back to summary |
|---|---|
| protected GenericType() Constructs a new generic type, deriving the generic type and class from type parameter. Note that this constructor is protected, users should create a (usually anonymous) subclass as shown above.
| |
| GenericType | back to summary |
|---|---|
| public GenericType(Type genericType) Constructs a new generic type, supplying the generic type information and deriving the class.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| forInstance | back to summary |
|---|---|
| public static GenericType Create a
If the supplied instance is a
| |
| getArrayClass | back to summary |
|---|---|
| private static Class Get Array class of component class. | |
| getClass | back to summary |
|---|---|
| private static Class Returns the object representing the class or interface that declared
the supplied | |
| getRawType | back to summary |
|---|---|
| public final Class Returns the object representing the class or interface that declared the type represented by this generic type instance.
| |
| getType | back to summary |
|---|---|
| public final Type getType() Retrieve the type represented by the generic type instance.
| |
| getTypeArgument | back to summary |
|---|---|
| pack-priv static Type getTypeArgument(Class<?> clazz, Class<?> baseClass) Return the value of the type parameter of | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |