public interface TypeDefinition extends NamedElement, ModifierReviewable.ForTypeDefinition, Iterable<TypeDefinition>
TypeDescription
or as a TypeDescription.Generic
.Modifier and Type | Interface and Description |
---|---|
static class |
TypeDefinition.Sort
Represents a
TypeDescription.Generic 's form. |
static class |
TypeDefinition.SuperClassIterator
An iterator that iterates over a type's class hierarchy.
|
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
ModifierReviewable.AbstractBase, ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
Modifier and Type | Field and Description |
---|---|
static String |
RAW_TYPES_PROPERTY
If this property is set to
true , non-generic TypeDefinition s do no longer resolve their referenced
generic types when traversing type hierarchies. |
EMPTY_NAME, NO_NAME
EMPTY_MASK
Modifier and Type | Method and Description |
---|---|
TypeDescription |
asErasure()
Returns the erasure of this type.
|
TypeDescription.Generic |
asGenericType()
Returns this type definition as a generic type.
|
TypeDefinition |
getComponentType()
Returns the component type of this type.
|
FieldList<?> |
getDeclaredFields()
Returns the fields that this type declares.
|
MethodList<?> |
getDeclaredMethods()
Returns the methods that this type declares.
|
TypeList.Generic |
getInterfaces()
Returns the interfaces that this type implements.
|
RecordComponentList<?> |
getRecordComponents()
Returns the list of record components that are declared by this type.
|
TypeDefinition.Sort |
getSort()
Returns the sort of the generic type this instance represents.
|
StackSize |
getStackSize()
Returns the size of the type described by this instance.
|
TypeDescription.Generic |
getSuperClass()
Returns the super class of this type.
|
String |
getTypeName()
Returns the name of the type.
|
boolean |
isArray()
Checks if the type described by this entity is an array.
|
boolean |
isPrimitive()
Checks if the type described by this entity is a primitive type.
|
boolean |
isRecord()
Checks if this type is a Java record.
|
boolean |
represents(Type type)
Checks if the type described by this instance represents
type . |
getActualName
getTypeManifestation, isAnnotation, isInterface
isAbstract
getEnumerationState, isEnum
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
getModifiers, getSyntheticState, isFinal, isSynthetic
forEach, iterator, spliterator
static final String RAW_TYPES_PROPERTY
If this property is set to true
, non-generic TypeDefinition
s do no longer resolve their referenced
generic types when traversing type hierarchies. Setting this property can cause unexpected side effects such as
ClassCastException
s from overridden methods as type variables are resolved to their erasures where a method
might return that is unexpected by the callee. Setting this property also makes type annotations unavailable using
such type navigation.
Setting this property can be useful if generic type information is not required in order to avoid bugs in implementations of the JVM where processing generic types can cause segmentation faults. Byte Buddy will undertake a best effort to retain the generic type information and information about type annotations within the redefined types' class files. Typically, this property can be meaningful in combination with a Java agent that only changes byte code without changing a class type's structure.
TypeDescription.Generic asGenericType()
TypeDescription asErasure()
TypeDescription.Generic.Sort#WILDCARD
)
do not have a well-defined erasure and cause an IllegalStateException
to be thrown.TypeDescription.Generic getSuperClass()
TypeDefinition.Sort.NON_GENERIC
),
parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types. Interface types
and the Object
class do not define a super class where null
is returned. Array types define Object
as their direct super class.null
if no super class exists for this type.TypeList.Generic getInterfaces()
TypeDefinition.Sort.NON_GENERIC
),
parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types.FieldList<?> 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.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<?> getDeclaredMethods()
TypeDefinition 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.
null
if this type does not represent an array type.RecordComponentList<?> getRecordComponents()
TypeDefinition.Sort getSort()
String getTypeName()
Object.toString()
representations. For a non-generic
type, it is the fully qualified binary name of the type.StackSize getStackSize()
TypeDescription.Generic.Sort#WILDCARD
do not have a well-defined a stack size and
cause an IllegalStateException
to be thrown.boolean isArray()
true
if this type description represents an array.boolean isRecord()
true
if this type is a Java record.boolean isPrimitive()
true
if this type description represents a primitive type.boolean represents(Type type)
type
.type
- The type of interest.true
if the type described by this instance represents type
.Copyright © 2014–2020. All rights reserved.