Interface TypeDescription.Generic
- All Superinterfaces:
AnnotationSource, Iterable<TypeDefinition>, ModifierReviewable, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration, NamedElement, TypeDefinition
- All Known Implementing Classes:
TypeDescription.Generic.AbstractBase, TypeDescription.Generic.LazyProjection, TypeDescription.Generic.LazyProjection.ForLoadedFieldType, TypeDescription.Generic.LazyProjection.ForLoadedReturnType, TypeDescription.Generic.LazyProjection.ForLoadedSuperClass, TypeDescription.Generic.LazyProjection.OfConstructorParameter, TypeDescription.Generic.LazyProjection.OfMethodParameter, TypeDescription.Generic.LazyProjection.OfRecordComponent, TypeDescription.Generic.LazyProjection.WithEagerNavigation, TypeDescription.Generic.LazyProjection.WithEagerNavigation.OfAnnotatedElement, TypeDescription.Generic.LazyProjection.WithLazyNavigation, TypeDescription.Generic.LazyProjection.WithLazyNavigation.LazyInterfaceType, TypeDescription.Generic.LazyProjection.WithLazyNavigation.LazySuperClass, TypeDescription.Generic.LazyProjection.WithLazyNavigation.OfAnnotatedElement, TypeDescription.Generic.LazyProjection.WithResolvedErasure, TypeDescription.Generic.OfGenericArray, TypeDescription.Generic.OfGenericArray.ForLoadedType, TypeDescription.Generic.OfGenericArray.Latent, TypeDescription.Generic.OfNonGenericType, TypeDescription.Generic.OfNonGenericType.ForErasure, TypeDescription.Generic.OfNonGenericType.ForLoadedType, TypeDescription.Generic.OfNonGenericType.ForReifiedErasure, TypeDescription.Generic.OfNonGenericType.Latent, TypeDescription.Generic.OfParameterizedType, TypeDescription.Generic.OfParameterizedType.ForGenerifiedErasure, TypeDescription.Generic.OfParameterizedType.ForLoadedType, TypeDescription.Generic.OfParameterizedType.ForReifiedType, TypeDescription.Generic.OfParameterizedType.Latent, TypeDescription.Generic.OfTypeVariable, TypeDescription.Generic.OfTypeVariable.ForLoadedType, TypeDescription.Generic.OfTypeVariable.Symbolic, TypeDescription.Generic.OfTypeVariable.WithAnnotationOverlay, TypeDescription.Generic.OfWildcardType, TypeDescription.Generic.OfWildcardType.ForLoadedType, TypeDescription.Generic.OfWildcardType.Latent, TypeDescription.Generic.Visitor.AnnotationStripper.NonAnnotatedTypeVariable, TypeDescription.Generic.Visitor.Substitutor.ForTypeVariableBinding.RetainedMethodTypeVariable, TypeDescription.SuperTypeLoading.ClassLoadingTypeProjection, TypeList.Generic.ForDetachedTypes.OfTypeVariables.AttachedTypeVariable, TypeList.Generic.OfConstructorExceptionTypes.TypeProjection, TypeList.Generic.OfLoadedInterfaceTypes.TypeProjection, TypeList.Generic.OfMethodExceptionTypes.TypeProjection, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForGenericArray.LazyGenericArray, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForLowerBoundWildcard.LazyLowerBoundWildcard, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForParameterizedType.LazyParameterizedType, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForParameterizedType.Nested.LazyParameterizedType, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForPrimitiveType.LazyPrimitiveType, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.AnnotatedTypeVariable, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.Formal.LazyTypeVariable, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.UnresolvedTypeVariable, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForUnboundWildcard.LazyUnboundWildcard, TypePool.Default.LazyTypeDescription.GenericTypeToken.ForUpperBoundWildcard.LazyUpperBoundWildcard, TypePool.Default.LazyTypeDescription.GenericTypeToken.Resolution.Raw.RawAnnotatedType, TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyNonGenericReceiverType, TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyParameterizedReceiverType, TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyParameterizedReceiverType.TypeArgumentList.AnnotatedTypeVariable, TypePool.Default.LazyTypeDescription.TokenizedGenericType, TypePool.Default.LazyTypeDescription.TokenizedGenericType.Malformed, TypePool.Default.WithLazyResolution.ExtendedLazyTypeDescription.LazyInterface, TypePool.Default.WithLazyResolution.ExtendedLazyTypeDescription.LazySuperClass
- Enclosing interface:
TypeDescription
Represents a generic type of the Java programming language. A non-generic TypeDescription is considered to be
a specialization of a generic type.
Note that annotations that are declared on an annotated type refer to any type annotations that are declared by this
generic type. For reading annotations of the erasure type, TypeDefinition.asErasure() must be called before.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAn abstract base implementation of a generic type description.static interfaceAn annotation reader is responsible for lazily evaluating type annotations if this language feature is available on the current JVM.static classA builder for creating describing a generic type as aTypeDescription.Generic.static classA lazy projection of a generic type.static classA lazy proxy for representing aTypeDescription.Genericfor a loaded type.static classA base implementation of a generic type description that represents a potentially generic array.static classA raw type representation of a non-generic type.static classA base implementation of a generic type description that represents a parameterized type.static classA base implementation of a generic type description that represents a type variable.static classA base implementation of a generic type description that represents a wildcard type.static interfaceA visitor that can be applied to aTypeDescription.Genericfor differentiating on the sort of the visited type.Nested classes/interfaces inherited from interface AnnotationSource
AnnotationSource.Empty, AnnotationSource.ExplicitNested classes/interfaces inherited from interface ModifierReviewable
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForModuleDescription, ModifierReviewable.ForModuleRequirement, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration, ModifierReviewable.OfMandatableNested classes/interfaces inherited from interface NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeNameNested classes/interfaces inherited from interface TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TypeDescription.GenericDeprecated.static final TypeDescription.GenericDeprecated.static final TypeDescription.GenericDeprecated.static final TypeDescription.GenericRepresents any undefined property representing a generic type description that is instead represented asnullin order to resemble the Java reflection API which returnsnulland is intuitive to many Java developers.static final TypeDescription.GenericDeprecated.Fields inherited from interface ModifierReviewable
EMPTY_MASKFields inherited from interface NamedElement
EMPTY_NAME, NO_NAMEFields inherited from interface TypeDefinition
RAW_TYPES_PROPERTY -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(TypeDescription.Generic.Visitor<T> visitor) Applies a visitor to this generic type description.Returns this type as a raw type.findBindingOf(TypeDescription.Generic typeVariable) Returns the parameter binding of the supplied type variable.Returns the component type of this type.Returns the fields that this type declares.Returns the methods that this type declares.Returns the lower bounds of this type.Returns the owner type of this type.Returns the list of record components that are declared by this type.Returns the symbol of this type variable.Returns the type arguments of this type.Returns the source of this type variable.Returns the upper bounds of this type.Methods inherited from interface AnnotationSource
getDeclaredAnnotationsMethods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface ModifierReviewable
getModifiers, getSyntheticState, isFinal, isSyntheticMethods inherited from interface ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterfaceMethods inherited from interface ModifierReviewable.OfAbstraction
isAbstractMethods inherited from interface ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStaticMethods inherited from interface ModifierReviewable.OfEnumeration
getEnumerationState, isEnumMethods inherited from interface NamedElement
getActualNameMethods inherited from interface TypeDefinition
asErasure, asGenericType, getInterfaces, getSort, getStackSize, getSuperClass, getTypeName, isArray, isPrimitive, isRecord, represents
-
Field Details
-
OBJECT
Deprecated.A representation of theObjecttype. -
CLASS
Deprecated.A representation of theClassnon-type. -
VOID
Deprecated.A representation of thevoidnon-type. -
ANNOTATION
Deprecated.A representation of theAnnotationtype. -
UNDEFINED
Represents any undefined property representing a generic type description that is instead represented asnullin order to resemble the Java reflection API which returnsnulland is intuitive to many Java developers.
-
-
Method Details
-
asRawType
TypeDescription.Generic asRawType()Returns this type as a raw type. This resembles callingasErasure().asGenericType().- Returns:
- This type as a raw type.
-
getUpperBounds
TypeList.Generic getUpperBounds()Returns the upper bounds of this type. Any type with a well-defined upper bound is bound by at least one type. If no such type is defined, the bound is implicitly
Object.Only non-symbolic type variables (
TypeDefinition.Sort.VARIABLE, and wildcard types (TypeDefinition.Sort.WILDCARD) have well-defined upper bounds. For other types, anIllegalStateExceptionis thrown.- Returns:
- The upper bounds of this type.
-
getLowerBounds
TypeList.Generic getLowerBounds()Returns the lower bounds of this type.
Only wildcard types (
TypeDefinition.Sort.WILDCARD) define a lower bound. For other types, anIllegalStateExceptionis thrown.- Returns:
- The lower bounds of this type.
-
getTypeArguments
TypeList.Generic getTypeArguments()Returns the type arguments of this type.
Parameters are only well-defined for parameterized types (
TypeDefinition.Sort.PARAMETERIZED). For all other types, this method throws anIllegalStateException.- Returns:
- A list of this type's type parameters.
-
getOwnerType
Returns the owner type of this type. A type's owner type describes a nested type's declaring type. If it exists, the returned type can be a non-generic or parameterized type. If a class has no declaring type,
nullis returned.An owner type is only well-defined for parameterized types (
TypeDefinition.Sort.PARAMETERIZED), for non-generic types (TypeDefinition.Sort.NON_GENERIC) and for generic arrays (TypeDefinition.Sort.GENERIC_ARRAY). For all other types, this method throws anIllegalStateException.- Returns:
- This type's owner type or
nullif no owner type exists.
-
findBindingOf
Returns the parameter binding of the supplied type variable.
This method must only be called for parameterized types (
TypeDefinition.Sort.PARAMETERIZED). For all other types, this method throws anIllegalStateException.- Parameters:
typeVariable- The type variable for which a value should be located.- Returns:
- The value that is bound to the supplied type variable or
nullif the type variable is not bound by this parameterized type.
-
getTypeVariableSource
TypeVariableSource getTypeVariableSource()Returns the source of this type variable. A type variable source is only well-defined for an attached type variable (TypeDefinition.Sort.VARIABLE. For other types, this method throws anIllegalStateException.- Returns:
- This type's type variable source.
-
getSymbol
String getSymbol()Returns the symbol of this type variable. A symbol is only well-defined for type variables (TypeDefinition.Sort.VARIABLE,TypeDefinition.Sort.VARIABLE_SYMBOLIC). For other types, this method throws anIllegalStateException.- Returns:
- This type's type variable symbol.
-
getComponentType
Returns the component type of this type.
Only non-generic types (
TypeDefinition.Sort.NON_GENERIC) and generic array typesTypeDefinition.Sort.GENERIC_ARRAY) define a component type. For other types, anIllegalStateExceptionis thrown.- Specified by:
getComponentTypein interfaceTypeDefinition- Returns:
- The component type of this type or
nullif this type does not represent an array type.
-
getDeclaredFields
FieldList<FieldDescription.InGenericShape> getDeclaredFields()Returns the fields that this type declares. A super type is only defined for non-generic types (TypeDefinition.Sort.NON_GENERIC), parameterized types (TypeDefinition.Sort.PARAMETERIZED) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY) types. Generic array types never define fields and the returned list is always empty for such types.- Specified by:
getDeclaredFieldsin interfaceTypeDefinition- Returns:
- The fields that this type declares. A super type is only defined for non-generic types (
TypeDefinition.Sort.NON_GENERIC), parameterized types (TypeDefinition.Sort.PARAMETERIZED) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY) types. Generic array types never define methods and the returned list is always empty for such types.
-
getDeclaredMethods
MethodList<MethodDescription.InGenericShape> getDeclaredMethods()Returns the methods that this type declares.- Specified by:
getDeclaredMethodsin interfaceTypeDefinition- Returns:
- The methods that this type declares.
-
getRecordComponents
RecordComponentList<RecordComponentDescription.InGenericShape> getRecordComponents()Returns the list of record components that are declared by this type. If this type is not a record, the returned list is empty.- Specified by:
getRecordComponentsin interfaceTypeDefinition- Returns:
- A list of record components that this type declares.
-
accept
Applies a visitor to this generic type description.- Type Parameters:
T- The value that this visitor yields.- Parameters:
visitor- The visitor to apply.- Returns:
- The visitor's return value.
-
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(Class)instead.J