public class GenericClassType extends ParameterizedType
InstantiatedType by instantiating with a Substitution.| Modifier and Type | Field and Description |
|---|---|
private java.util.List<TypeVariable> |
parameters
The type parameters of the generic class.
|
private java.lang.Class<?> |
rawType
The rawtype of the generic class.
|
enclosingType| Constructor and Description |
|---|
GenericClassType(java.lang.Class<?> rawType)
Creates a
GenericClassType for the given raw type. |
| Modifier and Type | Method and Description |
|---|---|
GenericClassType |
applyCaptureConversion()
Applies a capture conversion to this type.
|
boolean |
equals(@Nullable java.lang.Object obj) |
GenericClassType |
getGenericClassType()
Returns the
GenericClassType for this parameterized type. |
java.util.List<ClassOrInterfaceType> |
getInterfaces()
Returns the interface types directly implemented by this class or interface type.
|
(package private) java.util.List<ClassOrInterfaceType> |
getInterfaces(Substitution substitution)
Return the directly-implemented interface types for this generic class type, instantiated by
the given type
Substitution. |
NonParameterizedType |
getRawtype()
Returns the rawtype
Type for this generic class. |
java.lang.Class<?> |
getRuntimeClass()
Returns the runtime
Class object for this type. |
ClassOrInterfaceType |
getSuperclass()
Return the type for the superclass for this class.
|
(package private) ClassOrInterfaceType |
getSuperclass(Substitution substitution)
Returns the superclass type for this generic class type instantiated by the given type
Substitution. |
java.util.List<TypeArgument> |
getTypeArguments()
Returns the type arguments for this type.
|
java.util.List<TypeVariable> |
getTypeParameters()
Returns the list of type parameters of this generic class.
|
int |
hashCode() |
InstantiatedType |
instantiate(java.util.List<ReferenceType> typeArguments)
Creates a type substitution using the given type arguments and applies it to this type.
|
InstantiatedType |
instantiate(ReferenceType... typeArguments)
Creates a type substitution using the given type arguments and applies it to this type.
|
boolean |
isAbstract()
Indicate whether this class is abstract.
|
boolean |
isGeneric(boolean ignoreWildcards)
Indicate whether this type is generic.
|
boolean |
isInterface()
Indicates whether this object is an interface type.
|
boolean |
isStatic()
Indicates whether this class is static.
|
boolean |
isSubtypeOf(Type otherType)
Test whether this type is a subtype of the given type according to transitive closure of
definition of the direct supertype relation in section 4.10.2
of JLS for JavaSE 8.
|
InstantiatedType |
substitute(Substitution substitution)
Instantiates this generic class using the substitution to replace the type parameters.
|
forClass, forType, getBinaryName, getFqName, getUnqualifiedBinaryNameapplyCaptureConversion, getAllSupertypesInclusive, getCanonicalName, getImmediateSupertypes, getInstantiatingSubstitution, getMatchingSupertype, getPackage, getPackagePrefix, getSimpleName, getSuperTypes, hasCaptureVariable, hasWildcard, isClassOrInterfaceType, isInstantiationOf, isMemberClass, isNestedClass, isParameterized, substitutegetInstantiatingSubstitutionforTypeVariable, isAssignableFrom, isCaptureVariable, isReferenceTypecompareTo, forFullyQualifiedName, forName, forValue, getTypeforFullyQualifiedName, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isEnum, isGeneric, isNonreceiverType, isObject, isPrimitive, isRawtype, isString, isVariable, isVoid, runtimeClassIs, toStringprivate java.lang.Class<?> rawType
private java.util.List<TypeVariable> parameters
GenericClassType(java.lang.Class<?> rawType)
GenericClassType for the given raw type.rawType - the Class raw typepublic boolean equals(@Nullable java.lang.Object obj)
Checks that the rawtypes are the same. This is sufficient since the type parameters and their bounds can be reconstructed from the Class object. Also, parameters can be distinct depending on how this object is constructed.
equals in class ClassOrInterfaceTypepublic int hashCode()
hashCode in class ClassOrInterfaceTypepublic InstantiatedType substitute(Substitution substitution)
substitute in class ParameterizedTypesubstitution - the type substitutionParameterizedType instantiating this generic class by the given substitutionpublic GenericClassType applyCaptureConversion()
TypeapplyCaptureConversion in class ClassOrInterfaceTypepublic java.util.List<ClassOrInterfaceType> getInterfaces()
Class.getGenericInterfaces(). If no interfaces are
implemented, then returns the empty list.
Note that this method uses Class.getInterfaces() and does not preserve the
relationship between the type parameters of a class and its interfaces, and should not be used
when finding supertypes of types represented as InstantiatedType objects.
getInterfaces in class ClassOrInterfaceTypejava.util.List<ClassOrInterfaceType> getInterfaces(Substitution substitution)
Substitution.
This method is not public. It is used when finding the interfaces of an InstantiatedType using InstantiatedType.getInterfaces(), where it is important that
the relationship between type variables is preserved. The reflection method Class.getGenericInterfaces() ensures the type variable objects are the same from a class to
its interfaces, which allows the use of the same substitution for both types.
substitution - the type substitutionpublic GenericClassType getGenericClassType()
ParameterizedTypeGenericClassType for this parameterized type.getGenericClassType in class ParameterizedTypepublic java.lang.Class<?> getRuntimeClass()
TypeClass object for this type. For use when reflection is needed.
Note that type variables and the null reference type do not have a runtime class, and this method will return null in those cases.
This method should not be confused with the inherited Object.getClass() method,
which returns the Class<?> for the Type object, and not of the represented
type. For instance, if a Type object t represented the Java type int,
then t.getRuntimeClass() would return int.class while t.getClass()
would return Type.class.
getRuntimeClass in class TypeClass that is the runtime representation of the type, or null if this type
is a type variable or null reference typepublic ClassOrInterfaceType getSuperclass()
Note that this method uses Class.getSuperclass() and does not preserve the
relationship between the type parameters of a class and its superclass, and should not be used
when finding supertypes of types represented as InstantiatedType objects.
getSuperclass in class ClassOrInterfaceTypeObject type if this type has no superclassClassOrInterfaceType getSuperclass(Substitution substitution)
Substitution.
This method is not public. It is used when finding the superclass of an InstantiatedType using InstantiatedType.getSuperclass(), where it is important that
the relationship between type variables is preserved. The reflection method Class.getGenericSuperclass() ensures the type variable objects are the same from subclass to
superclass, which allows the use of the same substitution for both types.
substitution - the type substitutionpublic java.util.List<TypeArgument> getTypeArguments()
ClassOrInterfaceTypegetTypeArguments in class ClassOrInterfaceTypepublic java.util.List<TypeVariable> getTypeParameters()
getTypeParameters in class ClassOrInterfaceTypepublic InstantiatedType instantiate(ReferenceType... typeArguments)
typeArguments - the type argumentssubstitute(Substitution)public InstantiatedType instantiate(java.util.List<ReferenceType> typeArguments)
typeArguments - the type argumentssubstitute(Substitution)public boolean isAbstract()
ClassOrInterfaceTypeisAbstract in class ClassOrInterfaceTypepublic boolean isGeneric(boolean ignoreWildcards)
TypeisGeneric in class ClassOrInterfaceTypeignoreWildcards - if true, ignore wildcards; that is, treat wildcards as not making the
operation genericpublic boolean isInterface()
TypeisInterface in class Typepublic boolean isStatic()
ClassOrInterfaceTypeisStatic in class ClassOrInterfaceTypepublic boolean isSubtypeOf(Type otherType)
Handles the specific cases of supertypes of a generic class C<F1,...,Fn> for which
the direct supertypes are:
Object, and
C
isSubtypeOf in class ClassOrInterfaceTypeotherType - the possible supertypeReferenceType.isAssignableFrom(Type),
ClassOrInterfaceType.isSubtypeOf(Type)public NonParameterizedType getRawtype()
Type for this generic class.getRawtype in class ClassOrInterfaceType