public interface TypeDescription extends TypeDefinition, ByteCodeElement, TypeVariableSource
Generic.Sort#NON_GENERIC.| Modifier and Type | Interface and Description |
|---|---|
static class |
TypeDescription.AbstractBase
An abstract base implementation of a type description.
|
static class |
TypeDescription.ArrayProjection
A projection for an array type based on an existing
TypeDescription. |
static class |
TypeDescription.ForLoadedType
A type description implementation that represents a loaded type.
|
static class |
TypeDescription.ForPackageDescription
A type representation of a package description.
|
static interface |
TypeDescription.Generic
Represents a generic type of the Java programming language.
|
static class |
TypeDescription.Latent
A latent type description for a type without methods or fields.
|
static class |
TypeDescription.LazyProxy
A lazy proxy for representing a
TypeDescription for a loaded type. |
static class |
TypeDescription.SuperTypeLoading
A delegating type description that always attempts to load the super types of a delegate type.
|
TypeDefinition.Sort, TypeDefinition.SuperClassIteratorModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumerationByteCodeElement.Member, ByteCodeElement.Token<T extends ByteCodeElement.Token<T>>, ByteCodeElement.TypeDependant<T extends ByteCodeElement.TypeDependant<?,S>,S extends ByteCodeElement.Token<S>>NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeNameDeclaredByType.WithMandatoryDeclarationAnnotationSource.Empty, AnnotationSource.ExplicitTypeVariableSource.Visitor<T>| Modifier and Type | Field and Description |
|---|---|
static TypeList.Generic |
ARRAY_INTERFACES
A list of interfaces that are implicitly implemented by any array type.
|
static TypeDescription |
CLASS
Deprecated.
Use
TypeDescription.ForLoadedType.of(Class) instead. |
static TypeDescription |
OBJECT
Deprecated.
Use
TypeDescription.ForLoadedType.of(Class) instead. |
static TypeDescription |
STRING
Deprecated.
Use
TypeDescription.ForLoadedType.of(Class) instead. |
static TypeDescription |
THROWABLE
Deprecated.
Use
TypeDescription.ForLoadedType.of(Class) instead. |
static TypeDescription |
UNDEFINED
Represents any undefined property representing a 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 |
VOID
Deprecated.
Use
TypeDescription.ForLoadedType.of(Class) instead. |
RAW_TYPES_PROPERTYEMPTY_MASKNON_GENERIC_SIGNATUREEMPTY_NAME, NO_NAME| Modifier and Type | Method and Description |
|---|---|
TypeDescription |
asBoxed()
Returns a description of this type that represents this type as a boxed type for primitive types, unless its
void. |
TypeDescription |
asUnboxed()
Returns a description of this type that represents this type as an unboxed type for boxing types, unless its
Void. |
int |
getActualModifiers(boolean superFlag)
Returns the type's actual modifiers as present in the class file.
|
String |
getCanonicalName()
Returns the canonical name of this type if it exists.
|
ClassFileVersion |
getClassFileVersion()
Attempts to resolve the class file version of this type.
|
TypeDescription |
getComponentType()
Returns the component type of this type.
|
FieldList<FieldDescription.InDefinedShape> |
getDeclaredFields()
Returns the fields that this type declares.
|
MethodList<MethodDescription.InDefinedShape> |
getDeclaredMethods()
Returns the methods that this type declares.
|
TypeList |
getDeclaredTypes()
Returns a list of types that are declared by this type.
|
TypeDescription |
getDeclaringType()
Returns the declaring type of this instance.
|
Object |
getDefaultValue()
Returns the default value for this type, i.e.
|
MethodDescription.InDefinedShape |
getEnclosingMethod()
Returns a description of the method that encloses this type.
|
TypeDescription |
getEnclosingType()
Returns a description of this type's enclosing type if any.
|
AnnotationList |
getInheritedAnnotations()
Returns the annotations that this type declares or inherits from super types.
|
int |
getInnerClassCount()
Returns the amount of outer classes this type defines.
|
String |
getLongSimpleName()
Returns a form of a type's simple name which only shortens the package name but not the names of outer classes.
|
TypeDescription |
getNestHost()
Returns the nest host of this type.
|
TypeList |
getNestMembers()
Returns a list of members that are part of a nesting group.
|
PackageDescription |
getPackage()
Returns the package of the type described by this instance or
null if the described type
is a primitive type or an array. |
TypeList |
getPermittedSubtypes()
Returns the list of permitted direct subclasses if this class is a sealed class.
|
RecordComponentList<RecordComponentDescription.InDefinedShape> |
getRecordComponents()
Returns the list of record components that are declared by this type.
|
String |
getSimpleName()
Returns the simple name of this type.
|
boolean |
isAnnotationReturnType()
Checks if instances of this type can be returned from an annotation method.
|
boolean |
isAnnotationValue()
Checks if instances of this type can be used for describing an annotation value.
|
boolean |
isAnnotationValue(Object value)
Checks if instances of this type can be used for describing the given annotation value.
|
boolean |
isAnonymousType()
Checks if this type description represents an anonymous type.
|
boolean |
isAssignableFrom(Class<?> type)
Checks if this type is assignable from the type described by this instance, for example for
class Foo and class Bar extends Foo, this method would return true for
Foo.class.isAssignableFrom(Bar.class). |
boolean |
isAssignableFrom(TypeDescription typeDescription)
Checks if this type is assignable from the type described by this instance, for example for
class Foo and class Bar extends Foo, this method would return true for
Foo.class.isAssignableFrom(Bar.class). |
boolean |
isAssignableTo(Class<?> type)
Checks if this type is assignable from the type described by this instance, for example for
class Foo and class Bar extends Foo, this method would return true for
Bar.class.isAssignableTo(Foo.class). |
boolean |
isAssignableTo(TypeDescription typeDescription)
Checks if this type is assignable from the type described by this instance, for example for
class Foo and class Bar extends Foo, this method would return true for
Bar.class.isAssignableFrom(Foo.class). |
boolean |
isCompileTimeConstant()
Indicates if this type represents a compile-time constant, i.e.
|
boolean |
isInHierarchyWith(Class<?> type)
Returns
true if this type and the supplied type are in a type hierarchy with each other, i.e. |
boolean |
isInHierarchyWith(TypeDescription typeDescription)
Returns
true if this type and the supplied type are in a type hierarchy with each other, i.e. |
boolean |
isInnerClass()
Indicates if this class is an inner class.
|
boolean |
isInstance(Object value)
Checks if
value is an instance of the type represented by this instance. |
boolean |
isLocalType()
Checks if this type description represents a local type.
|
boolean |
isMemberType()
Checks if this type description represents a member type.
|
boolean |
isNestedClass()
Indicates if this class is a nested class.
|
boolean |
isNestHost()
Checks if this class is the host of a nest group.
|
boolean |
isNestMateOf(Class<?> type)
Checks if this type and the supplied type are members of the same nest group.
|
boolean |
isNestMateOf(TypeDescription typeDescription)
Checks if this type and the supplied type are members of the same nest group.
|
boolean |
isPackageType()
Checks if this type represents a class that is a place holder for a package description.
|
boolean |
isPrimitiveWrapper()
Checks if this type represents a wrapper type for a primitive type.
|
boolean |
isSamePackage(TypeDescription typeDescription)
Checks if two types are defined in the same package.
|
boolean |
isSealed()
Returns
true if this class is a sealed class that only permitts a specified range of subclasses. |
asErasure, asGenericType, getInterfaces, getSort, getStackSize, getSuperClass, getTypeName, isArray, isPrimitive, isRecord, representsgetTypeManifestation, isAnnotation, isInterfaceisAbstractgetEnumerationState, isEnumgetOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStaticgetModifiers, getSyntheticState, isFinal, isSyntheticforEach, iterator, spliteratorisAccessibleTo, isVisibleTogetInternalName, getNamegetDescriptor, getGenericSignaturegetActualNamegetDeclaredAnnotationsaccept, findExpectedVariable, findVariable, getEnclosingSource, getTypeVariables, isGenerified, isInferrable@Deprecated static final TypeDescription OBJECT
TypeDescription.ForLoadedType.of(Class) instead.Object type.@Deprecated static final TypeDescription STRING
TypeDescription.ForLoadedType.of(Class) instead.String type.@Deprecated static final TypeDescription CLASS
TypeDescription.ForLoadedType.of(Class) instead.Class type.@Deprecated static final TypeDescription THROWABLE
TypeDescription.ForLoadedType.of(Class) instead.Throwable type.@Deprecated static final TypeDescription VOID
TypeDescription.ForLoadedType.of(Class) instead.void non-type.static final TypeList.Generic ARRAY_INTERFACES
@AlwaysNull static final TypeDescription UNDEFINED
null in order
to resemble the Java reflection API which returns null and is intuitive to many Java developers.FieldList<FieldDescription.InDefinedShape> getDeclaredFields()
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 TypeDefinitionTypeDefinition.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.InDefinedShape> getDeclaredMethods()
getDeclaredMethods in interface TypeDefinitionRecordComponentList<RecordComponentDescription.InDefinedShape> getRecordComponents()
getRecordComponents in interface TypeDefinitionboolean isInstance(Object value)
value is an instance of the type represented by this instance.value - The object of interest.true if the object is an instance of the type described by this instance.boolean isAssignableFrom(Class<?> type)
class Foo and class Bar extends Foo, this method would return true for
Foo.class.isAssignableFrom(Bar.class).type - The type of interest.true if this type is assignable from type.boolean isAssignableFrom(TypeDescription typeDescription)
class Foo and class Bar extends Foo, this method would return true for
Foo.class.isAssignableFrom(Bar.class).
Implementations of this methods are allowed to delegate to
isAssignableFrom(Class)typeDescription - The type of interest.true if this type is assignable from type.boolean isAssignableTo(Class<?> type)
class Foo and class Bar extends Foo, this method would return true for
Bar.class.isAssignableTo(Foo.class).type - The type of interest.true if this type is assignable to type.boolean isAssignableTo(TypeDescription typeDescription)
class Foo and class Bar extends Foo, this method would return true for
Bar.class.isAssignableFrom(Foo.class).
Implementations of this methods are allowed to delegate to
isAssignableTo(Class)typeDescription - The type of interest.true if this type is assignable to type.boolean isInHierarchyWith(Class<?> type)
true if this type and the supplied type are in a type hierarchy with each other, i.e. if this type is assignable
to the supplied type or the other way around.type - The type of interest.true if this type and the supplied type are in a type hierarchy with each other.boolean isInHierarchyWith(TypeDescription typeDescription)
true if this type and the supplied type are in a type hierarchy with each other, i.e. if this type is assignable
to the supplied type or the other way around.typeDescription - The type of interest.true if this type and the supplied type are in a type hierarchy with each other.@MaybeNull TypeDescription getComponentType()
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 TypeDefinitionnull if this type does not represent an array type.@MaybeNull TypeDescription getDeclaringType()
getDeclaringType in interface DeclaredByTypenull if no such type exists.TypeList getDeclaredTypes()
@MaybeNull MethodDescription.InDefinedShape getEnclosingMethod()
null is returned by this method.null if there is no such method.@MaybeNull TypeDescription getEnclosingType()
null if there is no such type.int getActualModifiers(boolean superFlag)
private.
but it modifiers might reflect this property nevertheless if a class was defined as a private inner class. The
returned modifiers take also into account if the type is marked as Deprecated. Anonymous classes that are
enclosed in a static method or the type initializer are additionally marked as final as it is also done
by the Java compiler.superFlag - true if the modifier's super flag should be set.String getSimpleName()
String getLongSimpleName()
@MaybeNull String getCanonicalName()
null.boolean isAnonymousType()
true if this type description represents an anonymous type.boolean isLocalType()
true if this type description represents a local type.boolean isMemberType()
true if this type description represents a member type.@MaybeNull PackageDescription getPackage()
null if the described type
is a primitive type or an array.null if the described type
is a primitive type or an array.AnnotationList getInheritedAnnotations()
boolean isSamePackage(TypeDescription typeDescription)
typeDescription - The type of interest.true if this type and the given type are in the same package.boolean isPrimitiveWrapper()
Void type is
not considered to be a wrapper type.true if this type represents a wrapper type.boolean isAnnotationReturnType()
true if instances of this type can be returned from an annotation method.boolean isAnnotationValue()
true if instances of this type can be used for describing an annotation value.boolean isAnnotationValue(Object value)
value - The value that is supposed to describe the annotation value for this instance.true if instances of this type can be used for describing the given annotation value..boolean isPackageType()
true if this type represents a package description.int getInnerClassCount()
0 is returned.boolean isInnerClass()
true if this class is an inner class.boolean isNestedClass()
true if this class is a nested class.TypeDescription asBoxed()
void.TypeDescription asUnboxed()
Void.@MaybeNull Object getDefaultValue()
null for a reference type.
For void, null is returned.TypeDescription getNestHost()
TypeList getNestMembers()
boolean isNestHost()
true if this class is a nest group's host.boolean isNestMateOf(Class<?> type)
type - The type for which to check if it is a member of the same nest group.true if this type and the supplied type are members of the same nest group.boolean isNestMateOf(TypeDescription typeDescription)
typeDescription - The type for which to check if it is a member of the same nest group.true if this type and the supplied type are members of the same nest group.boolean isCompileTimeConstant()
int, long, float, double,
String, Class or java.lang.invoke.MethodHandle or java.lang.invoke.MethodType. Since Java 11's
*constantdynamic* any type can be considered a constant value; this method does however only consider classical compile time
constants.true if this type represents a compile-time constant.TypeList getPermittedSubtypes()
boolean isSealed()
true if this class is a sealed class that only permitts a specified range of subclasses.true if this class is a sealed class that only permitts a specified range of subclasses.@MaybeNull ClassFileVersion getClassFileVersion()
null is returned.null if it cannot be resolved.Copyright © 2014–2025. All rights reserved.