Interface TypeDescription.Generic
-
- All Superinterfaces:
AnnotationSource
,java.lang.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
- Enclosing interface:
- TypeDescription
public static interface TypeDescription.Generic extends TypeDefinition, AnnotationSource
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 Classes Modifier and Type Interface Description static class
TypeDescription.Generic.AbstractBase
An abstract base implementation of a generic type description.static interface
TypeDescription.Generic.AnnotationReader
An annotation reader is responsible for lazily evaluating type annotations if this language feature is available on the current JVM.static class
TypeDescription.Generic.Builder
A builder for creating describing a generic type as aTypeDescription.Generic
.static class
TypeDescription.Generic.LazyProjection
A lazy projection of a generic type.static class
TypeDescription.Generic.OfGenericArray
A base implementation of a generic type description that represents a potentially generic array.static class
TypeDescription.Generic.OfNonGenericType
A raw type representation of a non-generic type.static class
TypeDescription.Generic.OfParameterizedType
A base implementation of a generic type description that represents a parameterized type.static class
TypeDescription.Generic.OfTypeVariable
A base implementation of a generic type description that represents a type variable.static class
TypeDescription.Generic.OfWildcardType
A base implementation of a generic type description that represents a wildcard type.static interface
TypeDescription.Generic.Visitor<T>
A visitor that can be applied to aTypeDescription.Generic
for differentiating on the sort of the visited type.-
Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationSource
AnnotationSource.Empty, AnnotationSource.Explicit
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIterator
-
-
Field Summary
Fields Modifier and Type Field Description static TypeDescription.Generic
ANNOTATION
A representation of theAnnotation
type.static TypeDescription.Generic
CLASS
A representation of theClass
non-type.static TypeDescription.Generic
OBJECT
A representation of theObject
type.static TypeDescription.Generic
UNDEFINED
Represents any undefined property representing a generic type description that is instead represented asnull
in order to resemble the Java reflection API which returnsnull
and is intuitive to many Java developers.static TypeDescription.Generic
VOID
A representation of thevoid
non-type.-
Fields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASK
-
Fields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAME
-
Fields inherited from interface net.bytebuddy.description.type.TypeDefinition
RAW_TYPES_PROPERTY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
accept(TypeDescription.Generic.Visitor<T> visitor)
Applies a visitor to this generic type description.TypeDescription.Generic
asRawType()
Returns this type as a raw type.TypeDescription.Generic
findBindingOf(TypeDescription.Generic typeVariable)
Returns the parameter binding of the supplied type variable.TypeDescription.Generic
getComponentType()
Returns the component type of this type.FieldList<FieldDescription.InGenericShape>
getDeclaredFields()
Returns the fields that this type declares.MethodList<MethodDescription.InGenericShape>
getDeclaredMethods()
Returns the methods that this type declares.TypeList.Generic
getLowerBounds()
Returns the lower bounds of this type.TypeDescription.Generic
getOwnerType()
Returns the owner type of this type.RecordComponentList<RecordComponentDescription.InGenericShape>
getRecordComponents()
Returns the list of record components that are declared by this type.java.lang.String
getSymbol()
Returns the symbol of this type variable.TypeList.Generic
getTypeArguments()
Returns the type arguments of this type.TypeVariableSource
getTypeVariableSource()
Returns the source of this type variable.TypeList.Generic
getUpperBounds()
Returns the upper bounds of this type.-
Methods inherited from interface net.bytebuddy.description.annotation.AnnotationSource
getDeclaredAnnotations
-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable
getModifiers, getSyntheticState, isFinal, isSynthetic
-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterface
-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfAbstraction
isAbstract
-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfEnumeration
getEnumerationState, isEnum
-
Methods inherited from interface net.bytebuddy.description.NamedElement
getActualName
-
Methods inherited from interface net.bytebuddy.description.type.TypeDefinition
asErasure, asGenericType, getInterfaces, getSort, getStackSize, getSuperClass, getTypeName, isArray, isPrimitive, isRecord, represents
-
-
-
-
Field Detail
-
OBJECT
static final TypeDescription.Generic OBJECT
A representation of theObject
type.
-
CLASS
static final TypeDescription.Generic CLASS
A representation of theClass
non-type.
-
VOID
static final TypeDescription.Generic VOID
A representation of thevoid
non-type.
-
ANNOTATION
static final TypeDescription.Generic ANNOTATION
A representation of theAnnotation
type.
-
UNDEFINED
static final TypeDescription.Generic UNDEFINED
Represents any undefined property representing a generic type description that is instead represented asnull
in order to resemble the Java reflection API which returnsnull
and is intuitive to many Java developers.
-
-
Method Detail
-
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, anIllegalStateException
is 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, anIllegalStateException
is 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
TypeDescription.Generic 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,
null
is 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
null
if no owner type exists.
-
findBindingOf
TypeDescription.Generic findBindingOf(TypeDescription.Generic typeVariable)
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
null
if 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
java.lang.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
TypeDescription.Generic 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, anIllegalStateException
is thrown.- Specified by:
getComponentType
in interfaceTypeDefinition
- Returns:
- The component type of this type or
null
if 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:
getDeclaredFields
in 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:
getDeclaredMethods
in 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:
getRecordComponents
in interfaceTypeDefinition
- Returns:
- A list of record components that this type declares.
-
accept
<T> T accept(TypeDescription.Generic.Visitor<T> visitor)
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.
-
-