public static interface TypeDescription.Generic extends TypeDefinition, AnnotatedCodeElement
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.
Modifier and Type | Interface and 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 evaluting 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 a
TypeDescription.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 a
TypeDescription.Generic for differentiating on the sort of the visited type. |
TypeDefinition.Sort, TypeDefinition.SuperClassIterator
NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
Modifier and Type | Field and Description |
---|---|
static TypeDescription.Generic |
ANNOTATION
A representation of the
Annotation type. |
static TypeDescription.Generic |
OBJECT
A representation of the
Object type. |
static TypeDescription.Generic |
UNDEFINED
Represents any undefined property representing a generic type description that is instead represented as
null in order
to resemble the Java reflection API which returns null and is intuitive to many Java developers. |
static TypeDescription.Generic |
VOID
A representation of the
void non-type. |
EMPTY_NAME, NO_NAME
Modifier and Type | Method and 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 |
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.
|
String |
getSymbol()
Returns the symbol of this type variable.
|
TypeList.Generic |
getTypeArguments()
Returns the type arguments of this type.
|
TypeList.Generic |
getUpperBounds()
Returns the upper bounds of this type.
|
TypeVariableSource |
getVariableSource()
Returns the source of this type variable.
|
asErasure, asGenericType, getInterfaces, getSort, getStackSize, getSuperClass, getTypeName, isArray, isPrimitive, represents
getActualName
forEach, iterator, spliterator
getDeclaredAnnotations
static final TypeDescription.Generic OBJECT
Object
type.static final TypeDescription.Generic VOID
void
non-type.static final TypeDescription.Generic ANNOTATION
Annotation
type.static final TypeDescription.Generic UNDEFINED
null
in order
to resemble the Java reflection API which returns null
and is intuitive to many Java developers.TypeDescription.Generic asRawType()
asErasure().asGenericType()
.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, an IllegalStateException
is thrown.
TypeList.Generic getLowerBounds()
Returns the lower bounds of this type.
Only wildcard types (Sort#WILDCARD
) define a lower bound. For other
types, an IllegalStateException
is thrown.
TypeList.Generic getTypeArguments()
Returns the type arguments of this type.
Parameters are only well-defined for parameterized types (Sort#PARAMETERIZED
).
For all other types, this method throws an IllegalStateException
.
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 (Sort#PARAMETERIZED
),
for non-generic types (Sort#NON_GENERIC
) and for generic arrays (Sort#GENERIC_ARRAY
).
For all other types, this method throws an IllegalStateException
.
null
if no owner type exists.TypeVariableSource getVariableSource()
Sort#VARIABLE
. For other types, this method
throws an IllegalStateException
.String getSymbol()
Sort#VARIABLE
, Sort#VARIABLE_SYMBOLIC
). For other types, this method
throws an IllegalStateException
.TypeDescription.Generic getComponentType()
TypeDefinition
Returns the component type of this type.
Only non-generic types (TypeDescription.Generic.Sort#NON_GENERIC
) and generic array types
TypeDescription.Generic.Sort#GENERIC_ARRAY
) define a component type. For other
types, an IllegalStateException
is thrown.
getComponentType
in interface TypeDefinition
null
if this type does not represent an array type.FieldList<FieldDescription.InGenericShape> getDeclaredFields()
TypeDefinition
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.getDeclaredFields
in interface TypeDefinition
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.MethodList<MethodDescription.InGenericShape> getDeclaredMethods()
TypeDefinition
getDeclaredMethods
in interface TypeDefinition
<T> T accept(TypeDescription.Generic.Visitor<T> visitor)
T
- The value that this visitor yields.visitor
- The visitor to apply.Copyright © 2014–2016. All rights reserved.