public static class TypeDescription.ForLoadedType extends TypeDescription.AbstractBase implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
protected static interface |
TypeDescription.ForLoadedType.Dispatcher
A dispatcher for using methods of
Class that are not declared for Java 6. |
TypeDescription.AbstractBase.OfSimpleType
TypeDescription.AbstractBase, TypeDescription.ArrayProjection, TypeDescription.ForLoadedType, TypeDescription.ForPackageDescription, TypeDescription.Generic, TypeDescription.Latent, TypeDescription.SuperTypeLoading
TypeDefinition.Sort, TypeDefinition.SuperClassIterator
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
ByteCodeElement.Token<T extends ByteCodeElement.Token<T>>, ByteCodeElement.TypeDependant<T extends ByteCodeElement.TypeDependant<?,S>,S extends ByteCodeElement.Token<S>>
NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
AnnotationSource.Empty, AnnotationSource.Explicit
TypeVariableSource.Visitor<T>
Modifier and Type | Field and Description |
---|---|
private static TypeDescription.ForLoadedType.Dispatcher |
DISPATCHER
A dispatcher for invking methods on
Class reflectively. |
private static long |
serialVersionUID
The class's serial version UID.
|
private java.lang.Class<?> |
type
The loaded type this instance represents.
|
private static java.util.Map<java.lang.Class<?>,TypeDescription> |
TYPE_CACHE
A cache of type descriptions for commonly used types to avoid unnecessary allocations.
|
RAW_TYPES
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOID
RAW_TYPES_PROPERTY
EMPTY_MASK
NON_GENERIC_SIGNATURE
EMPTY_NAME, NO_NAME
Constructor and Description |
---|
ForLoadedType(java.lang.Class<?> type)
Creates a new immutable type description for a loaded type.
|
Modifier and Type | Method and Description |
---|---|
TypeDescription.Generic |
asGenericType()
Returns this type definition as a generic type.
|
java.lang.String |
getCanonicalName()
Returns the canonical name of this type if it exists.
|
TypeDescription |
getComponentType()
Returns the component type of this type.
|
AnnotationList |
getDeclaredAnnotations()
Returns a list of annotations that are declared by this instance.
|
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.
|
java.lang.String |
getDescriptor()
Returns the descriptor of this byte code element.
|
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.
|
TypeList.Generic |
getInterfaces()
Returns the interfaces that this type implements.
|
int |
getModifiers()
Returns the modifier that is described by this object.
|
java.lang.String |
getName()
Returns the internalName of this byte code element.
|
static java.lang.String |
getName(java.lang.Class<?> type)
Returns the type's actual name where it is taken into consideration that this type might be loaded anonymously.
|
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 does not imply a package. |
java.lang.String |
getSimpleName()
Returns the simple internalName of this type.
|
StackSize |
getStackSize()
Returns the size of the type described by this instance.
|
TypeDescription.Generic |
getSuperClass()
Returns the super class of this type.
|
TypeList.Generic |
getTypeVariables()
Returns the type variables that are declared by this element.
|
boolean |
isAnnotation()
Specifies if the modifier described by this object represents the annotation flag.
|
boolean |
isAnonymousType()
Checks if this type description represents an anonymous type.
|
boolean |
isArray()
Checks if the type described by this entity is an array.
|
boolean |
isAssignableFrom(java.lang.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(java.lang.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 |
isInHierarchyWith(java.lang.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 |
isLocalType()
Checks if this type description represents a local type.
|
boolean |
isMemberType()
Checks if this type description represents a member type.
|
boolean |
isNestHost()
Checks if this class is the host of a nest group.
|
boolean |
isNestMateOf(java.lang.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 |
isPrimitive()
Checks if the type described by this entity is a primitive type.
|
static TypeDescription |
of(java.lang.Class<?> type)
Returns a new immutable type description for a loaded type.
|
boolean |
represents(java.lang.reflect.Type type)
Checks if the type described by this instance represents
type . |
accept, asBoxed, asErasure, asUnboxed, equals, getActualModifiers, getActualName, getDefaultValue, getEnclosingSource, getGenericSignature, getInheritedAnnotations, getInnerClassCount, getInternalName, getSort, getTypeName, hashCode, isAccessibleTo, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isGenerified, isInnerClass, isInstance, isNestedClass, isPackageType, isPrimitiveWrapper, isSamePackage, isVisibleTo, iterator, toString
findVariable
getEnumerationState, getFieldManifestation, getFieldPersistence, getMethodManifestation, getMethodStrictness, getOwnership, getParameterManifestation, getProvisioningState, getSynchronizationState, getSyntheticState, getTypeManifestation, getVisibility, isAbstract, isBridge, isDeprecated, isEnum, isFinal, isInterface, isMandated, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrict, isSynchronized, isSynthetic, isTransient, isVarArgs, isVolatile
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getTypeManifestation, isInterface
isAbstract
getEnumerationState, isEnum
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
getSyntheticState, isFinal, isSynthetic
findVariable
private static final long serialVersionUID
private static final TypeDescription.ForLoadedType.Dispatcher DISPATCHER
Class
reflectively.private static final java.util.Map<java.lang.Class<?>,TypeDescription> TYPE_CACHE
private final java.lang.Class<?> type
public ForLoadedType(java.lang.Class<?> type)
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(Class)
instead.type
- The type to be represented by this type description.public static java.lang.String getName(java.lang.Class<?> type)
/<id>
which is removed when using this method
but is retained when calling Class.getName()
.type
- The type for which to resolve its name.public static TypeDescription of(java.lang.Class<?> type)
type
- The type to be represented by this type description.public boolean isAssignableFrom(java.lang.Class<?> type)
TypeDescription.AbstractBase
class Foo
and class Bar extends Foo
, this method would return true
for
Foo.class.isAssignableFrom(Bar.class)
.isAssignableFrom
in interface TypeDescription
isAssignableFrom
in class TypeDescription.AbstractBase
type
- The type of interest.true
if this type is assignable from type
.public boolean isAssignableFrom(TypeDescription typeDescription)
TypeDescription.AbstractBase
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
TypeDescription.isAssignableFrom(Class)
isAssignableFrom
in interface TypeDescription
isAssignableFrom
in class TypeDescription.AbstractBase
typeDescription
- The type of interest.true
if this type is assignable from type
.public boolean isAssignableTo(java.lang.Class<?> type)
TypeDescription.AbstractBase
class Foo
and class Bar extends Foo
, this method would return true
for
Bar.class.isAssignableTo(Foo.class)
.isAssignableTo
in interface TypeDescription
isAssignableTo
in class TypeDescription.AbstractBase
type
- The type of interest.true
if this type is assignable to type
.public boolean isAssignableTo(TypeDescription typeDescription)
TypeDescription.AbstractBase
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
TypeDescription.isAssignableTo(Class)
isAssignableTo
in interface TypeDescription
isAssignableTo
in class TypeDescription.AbstractBase
typeDescription
- The type of interest.true
if this type is assignable to type
.public boolean isInHierarchyWith(java.lang.Class<?> type)
TypeDescription.AbstractBase
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.isInHierarchyWith
in interface TypeDescription
isInHierarchyWith
in class TypeDescription.AbstractBase
type
- The type of interest.true
if this type and the supplied type are in a type hierarchy with each other.public boolean isInHierarchyWith(TypeDescription typeDescription)
TypeDescription.AbstractBase
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.isInHierarchyWith
in interface TypeDescription
isInHierarchyWith
in class TypeDescription.AbstractBase
typeDescription
- The type of interest.true
if this type and the supplied type are in a type hierarchy with each other.public boolean represents(java.lang.reflect.Type type)
TypeDescription.AbstractBase
type
.represents
in interface TypeDefinition
represents
in class TypeDescription.AbstractBase
type
- The type of interest.true
if the type described by this instance represents type
.public 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 TypeDefinition
getComponentType
in interface TypeDescription
null
if this type does not represent an array type.public boolean isArray()
isArray
in interface TypeDefinition
true
if this type description represents an array.public boolean isPrimitive()
isPrimitive
in interface TypeDefinition
true
if this type description represents a primitive type.public boolean isAnnotation()
ModifierReviewable.AbstractBase
isAnnotation
in interface ModifierReviewable.ForTypeDefinition
isAnnotation
in class ModifierReviewable.AbstractBase
true
if the modifier described by this object represents the annotation flag.public 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.getSuperClass
in interface TypeDefinition
null
if no super class exists for this type.public TypeList.Generic getInterfaces()
TypeDefinition.Sort.NON_GENERIC
),
parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types.getInterfaces
in interface TypeDefinition
public TypeDescription getDeclaringType()
getDeclaringType
in interface DeclaredByType
getDeclaringType
in interface TypeDescription
null
if no such type exists.public MethodDescription.InDefinedShape getEnclosingMethod()
null
is returned by this method.getEnclosingMethod
in interface TypeDescription
null
if there is no such method.public TypeDescription getEnclosingType()
getEnclosingType
in interface TypeDescription
null
if there is no such type.public TypeList getDeclaredTypes()
getDeclaredTypes
in interface TypeDescription
public java.lang.String getSimpleName()
getSimpleName
in interface TypeDescription
public boolean isAnonymousType()
isAnonymousType
in interface TypeDescription
true
if this type description represents an anonymous type.public boolean isLocalType()
isLocalType
in interface TypeDescription
true
if this type description represents a local type.public boolean isMemberType()
TypeDescription.AbstractBase
isMemberType
in interface TypeDescription
isMemberType
in class TypeDescription.AbstractBase
true
if this type description represents a member type.@CachedReturnPlugin.Enhance(value="declaredFields") public 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 TypeDefinition
getDeclaredFields
in interface TypeDescription
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.@CachedReturnPlugin.Enhance(value="declaredMethods") public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods()
getDeclaredMethods
in interface TypeDefinition
getDeclaredMethods
in interface TypeDescription
public PackageDescription getPackage()
null
if the described type does not imply a package.getPackage
in interface TypeDescription
null
if the described type does not imply a package.public StackSize getStackSize()
TypeDescription.Generic.Sort#WILDCARD
do not have a well-defined a stack size and
cause an IllegalStateException
to be thrown.getStackSize
in interface TypeDefinition
public java.lang.String getName()
getName
in interface NamedElement.WithRuntimeName
public java.lang.String getCanonicalName()
getCanonicalName
in interface TypeDescription
null
.public java.lang.String getDescriptor()
getDescriptor
in interface ByteCodeElement
public int getModifiers()
getModifiers
in interface ModifierReviewable
public TypeList.Generic getTypeVariables()
getTypeVariables
in interface TypeVariableSource
@CachedReturnPlugin.Enhance(value="declaredAnnotations") public AnnotationList getDeclaredAnnotations()
getDeclaredAnnotations
in interface AnnotationSource
public TypeDescription.Generic asGenericType()
asGenericType
in interface TypeDefinition
asGenericType
in class TypeDescription.AbstractBase
public TypeDescription getNestHost()
getNestHost
in interface TypeDescription
public TypeList getNestMembers()
getNestMembers
in interface TypeDescription
public boolean isNestHost()
TypeDescription.AbstractBase
isNestHost
in interface TypeDescription
isNestHost
in class TypeDescription.AbstractBase
true
if this class is a nest group's host.public boolean isNestMateOf(java.lang.Class<?> type)
TypeDescription.AbstractBase
isNestMateOf
in interface TypeDescription
isNestMateOf
in class TypeDescription.AbstractBase
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.public boolean isNestMateOf(TypeDescription typeDescription)
TypeDescription.AbstractBase
isNestMateOf
in interface TypeDescription
isNestMateOf
in class TypeDescription.AbstractBase
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.