public abstract static class TypeDescription.AbstractBase extends TypeVariableSource.AbstractBase implements TypeDescription
Modifier and Type | Class and Description |
---|---|
static class |
TypeDescription.AbstractBase.OfSimpleType
An adapter implementation of a
TypeDescription that
describes any type that is not an array or a primitive type. |
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.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
AnnotationSource.Empty, AnnotationSource.Explicit
TypeVariableSource.Visitor<T>
Modifier and Type | Field and Description |
---|---|
static boolean |
RAW_TYPES
The
TypeDefinition.RAW_TYPES_PROPERTY property. |
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOID
RAW_TYPES_PROPERTY
EMPTY_MASK
NON_GENERIC_SIGNATURE
EMPTY_NAME, NO_NAME
Constructor and Description |
---|
AbstractBase() |
Modifier and Type | Method and Description |
---|---|
<T> T |
accept(TypeVariableSource.Visitor<T> visitor)
Applies a visitor on this type variable source.
|
TypeDescription |
asBoxed()
Returns a description of this type that represents this type as a boxed type for primitive types, unless its
void . |
TypeDescription |
asErasure()
Returns the erasure of this type.
|
TypeDescription.Generic |
asGenericType()
Returns this type definition as a generic type.
|
TypeDescription |
asUnboxed()
Returns a description of this type that represents this type as an unboxed type for boxing types, unless its
Void . |
boolean |
equals(Object other) |
int |
getActualModifiers(boolean superFlag)
Returns the type's actual modifiers as present in the class file.
|
String |
getActualName()
Returns the name of this element as it is found in the source code.
|
Object |
getDefaultValue()
Returns the default value for this type, i.e.
|
TypeVariableSource |
getEnclosingSource()
Returns the enclosing source of type variables that are valid in the scope of this type variable source.
|
String |
getGenericSignature()
Returns the generic signature of this byte code element.
|
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 |
getInternalName()
Returns the internal internalName of this byte code element.
|
TypeDefinition.Sort |
getSort()
Returns the sort of the generic type this instance represents.
|
String |
getTypeName()
Returns the name of the type.
|
int |
hashCode() |
boolean |
isAccessibleTo(TypeDescription typeDescription)
Checks if this element is accessible from a given 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 |
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 |
isGenerified()
Checks if this type variable source has a generic declaration.
|
boolean |
isInferrable()
Returns
true if type variables declared by this type variable source allow dynamic type inference. |
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 |
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. |
boolean |
isVisibleTo(TypeDescription typeDescription)
Checks if this element is visible from a given type.
|
Iterator<TypeDefinition> |
iterator() |
boolean |
represents(Type type)
Checks if the type described by this instance represents
type . |
String |
toString() |
findVariable
getEnumerationState, getFieldManifestation, getFieldPersistence, getMethodManifestation, getMethodStrictness, getOwnership, getParameterManifestation, getProvisioningState, getSynchronizationState, getSyntheticState, getTypeManifestation, getVisibility, isAbstract, isAnnotation, 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
getCanonicalName, getComponentType, getDeclaredFields, getDeclaredMethods, getDeclaredTypes, getDeclaringType, getEnclosingMethod, getEnclosingType, getNestHost, getNestMembers, getPackage, getPermittedSubclasses, getRecordComponents, getSimpleName, isAnonymousType, isLocalType
getInterfaces, getStackSize, getSuperClass, isArray, isPrimitive, isRecord
getTypeManifestation, isAnnotation, isInterface
isAbstract
getEnumerationState, isEnum
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
getModifiers, getSyntheticState, isFinal, isSynthetic
forEach, spliterator
getName
getDescriptor
getDeclaredAnnotations
findVariable, getTypeVariables
public static final boolean RAW_TYPES
TypeDefinition.RAW_TYPES_PROPERTY
property.public boolean isAssignableFrom(Class<?> type)
class Foo
and class Bar extends Foo
, this method would return true
for
Foo.class.isAssignableFrom(Bar.class)
.isAssignableFrom
in interface TypeDescription
type
- The type of interest.true
if this type is assignable from type
.public 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
TypeDescription.isAssignableFrom(Class)
isAssignableFrom
in interface TypeDescription
typeDescription
- The type of interest.true
if this type is assignable from type
.public boolean isAssignableTo(Class<?> type)
class Foo
and class Bar extends Foo
, this method would return true
for
Bar.class.isAssignableTo(Foo.class)
.isAssignableTo
in interface TypeDescription
type
- The type of interest.true
if this type is assignable to type
.public 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
TypeDescription.isAssignableTo(Class)
isAssignableTo
in interface TypeDescription
typeDescription
- The type of interest.true
if this type is assignable to type
.public 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.isInHierarchyWith
in interface TypeDescription
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)
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
typeDescription
- The type of interest.true
if this type and the supplied type are in a type hierarchy with each other.public TypeDescription asErasure()
TypeDescription.Generic.Sort#WILDCARD
)
do not have a well-defined erasure and cause an IllegalStateException
to be thrown.asErasure
in interface TypeDefinition
public TypeDescription.Generic asGenericType()
asGenericType
in interface TypeDefinition
public TypeDefinition.Sort getSort()
getSort
in interface TypeDefinition
public boolean isInstance(Object value)
value
is an instance of the type represented by this instance.isInstance
in interface TypeDescription
value
- The object of interest.true
if the object is an instance of the type described by this instance.public boolean isAnnotationValue(Object value)
isAnnotationValue
in interface TypeDescription
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..public String getInternalName()
getInternalName
in interface NamedElement.WithRuntimeName
public 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.getActualModifiers
in interface TypeDescription
superFlag
- true
if the modifier's super flag should be set.public String getGenericSignature()
null
is returned as a signature.getGenericSignature
in interface NamedElement.WithDescriptor
null
if this element is not generic.public boolean isSamePackage(TypeDescription typeDescription)
isSamePackage
in interface TypeDescription
typeDescription
- The type of interest.true
if this type and the given type are in the same package.public boolean isVisibleTo(TypeDescription typeDescription)
Checks if this element is visible from a given type. Visibility is a wider criteria then accessibility which can be checked by
ByteCodeElement.isAccessibleTo(TypeDescription)
. Visibility allows the invocation of a method on itself or on external
instances.
Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.
Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.
isVisibleTo
in interface ByteCodeElement
typeDescription
- The type which is checked for its visibility of this element.true
if this element is visible for typeDescription
.public boolean isAccessibleTo(TypeDescription typeDescription)
Checks if this element is accessible from a given type. Accessibility is a more narrow criteria then visibility which can be
checked by ByteCodeElement.isVisibleTo(TypeDescription)
. Accessibility allows the invocation of a method on external
instances or on itself. Methods that can be invoked from within an instance might however not be considered accessible.
Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.
Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.
isAccessibleTo
in interface ByteCodeElement
typeDescription
- The type which is checked for its accessibility of this element.true
if this element is accessible for typeDescription
.public AnnotationList getInheritedAnnotations()
getInheritedAnnotations
in interface TypeDescription
public String getActualName()
getActualName
in interface NamedElement
public boolean isPrimitiveWrapper()
Void
type is
not considered to be a wrapper type.isPrimitiveWrapper
in interface TypeDescription
true
if this type represents a wrapper type.public boolean isAnnotationReturnType()
isAnnotationReturnType
in interface TypeDescription
true
if instances of this type can be returned from an annotation method.public boolean isAnnotationValue()
isAnnotationValue
in interface TypeDescription
true
if instances of this type can be used for describing an annotation value.public boolean represents(Type type)
type
.represents
in interface TypeDefinition
type
- The type of interest.true
if the type described by this instance represents type
.public String getTypeName()
Object.toString()
representations. For a non-generic
type, it is the fully qualified binary name of the type.getTypeName
in interface TypeDefinition
public TypeVariableSource getEnclosingSource()
getEnclosingSource
in interface TypeVariableSource
null
if no such source exists.public boolean isInferrable()
true
if type variables declared by this type variable source allow dynamic type inference.isInferrable
in interface TypeVariableSource
true
if type variables declared by this type variable source allow dynamic type inference.public <T> T accept(TypeVariableSource.Visitor<T> visitor)
accept
in interface TypeVariableSource
T
- The visitor's return type.visitor
- The visitor to apply.public boolean isPackageType()
isPackageType
in interface TypeDescription
true
if this type represents a package description.public boolean isGenerified()
isGenerified
in interface TypeVariableSource
true
if this type code element has a generic declaration.public int getInnerClassCount()
0
is returned.getInnerClassCount
in interface TypeDescription
public boolean isInnerClass()
isInnerClass
in interface TypeDescription
true
if this class is an inner class.public boolean isNestedClass()
isNestedClass
in interface TypeDescription
true
if this class is a nested class.public TypeDescription asBoxed()
void
.asBoxed
in interface TypeDescription
public TypeDescription asUnboxed()
Void
.asUnboxed
in interface TypeDescription
public Object getDefaultValue()
null
for a reference type.
For void
, null
is returned.getDefaultValue
in interface TypeDescription
public boolean isNestHost()
isNestHost
in interface TypeDescription
true
if this class is a nest group's host.public boolean isNestMateOf(Class<?> type)
isNestMateOf
in interface TypeDescription
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)
isNestMateOf
in interface 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.public boolean isMemberType()
isMemberType
in interface TypeDescription
true
if this type description represents a member type.public boolean isCompileTimeConstant()
int
, long
, float
, double
,
String
, Class
or java.lang.invoke.MethodHandle
or java.lang.invoke.MethodType
.isCompileTimeConstant
in interface TypeDescription
true
if this type represents a compile-time constant.public boolean isSealed()
true
if this class is a sealed class that only permitts a specified range of subclasses.isSealed
in interface TypeDescription
true
if this class is a sealed class that only permitts a specified range of subclasses.public Iterator<TypeDefinition> iterator()
iterator
in interface Iterable<TypeDefinition>
@CachedReturnPlugin.Enhance public int hashCode()
Copyright © 2014–2020. All rights reserved.