Package com.fasterxml.classmate
Class ResolvedType
- java.lang.Object
-
- com.fasterxml.classmate.ResolvedType
-
- All Implemented Interfaces:
Type
- Direct Known Subclasses:
ResolvedArrayType
,ResolvedInterfaceType
,ResolvedObjectType
,ResolvedPrimitiveType
,ResolvedRecursiveType
,TypePlaceHolder
public abstract class ResolvedType extends Object implements Type
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>
_erasedType
protected TypeBindings
_typeBindings
Type bindings active when resolving members (methods, fields, constructors) of this typeprotected static RawConstructor[]
NO_CONSTRUCTORS
protected static RawField[]
NO_FIELDS
protected static RawMethod[]
NO_METHODS
static ResolvedType[]
NO_TYPES
-
Constructor Summary
Constructors Modifier Constructor Description protected
ResolvedType(Class<?> cls, TypeBindings bindings)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringBuilder
_appendClassDescription(StringBuilder sb)
protected StringBuilder
_appendClassName(StringBuilder sb)
protected StringBuilder
_appendClassSignature(StringBuilder sb)
protected StringBuilder
_appendErasedClassSignature(StringBuilder sb)
protected RawConstructor[]
_getConstructors()
protected RawField[]
_getFields(boolean statics)
protected RawMethod[]
_getMethods(boolean statics)
abstract StringBuilder
appendBriefDescription(StringBuilder sb)
abstract StringBuilder
appendErasedSignature(StringBuilder sb)
abstract StringBuilder
appendFullDescription(StringBuilder sb)
abstract StringBuilder
appendSignature(StringBuilder sb)
boolean
canCreateSubtype(Class<?> subtype)
Method that can be used to check if call toTypeResolver.resolveSubtype(ResolvedType, Class)
will succeed for specific type; if false, it will fail with an exception; if tru it will succeed.abstract boolean
canCreateSubtypes()
Method that can be used to check if call toTypeResolver.resolveSubtype(ResolvedType, Class)
may ever succeed; if false, it will fail with an exception, if true, it may succeed.boolean
equals(Object o)
ResolvedType
findSupertype(Class<?> erasedSupertype)
Method for finding super type of this type that has specified type erased signature.abstract ResolvedType
getArrayElementType()
Method that can be used to access element type of array types; will return null for non-array types, and non-null type for array types.String
getBriefDescription()
Human-readable brief description of type, which does not include information about super types.List<RawConstructor>
getConstructors()
String
getErasedSignature()
Method that returns type erased signature of the type; suitable as non-generic signature some packages needClass<?>
getErasedType()
Returns type-erased Class<?> that this resolved type has.String
getFullDescription()
Human-readable full description of type, which includes specification of super types (in brief format)abstract List<ResolvedType>
getImplementedInterfaces()
Returns ordered list of interfaces (in declaration order) that this type implements.List<RawField>
getMemberFields()
List<RawMethod>
getMemberMethods()
abstract ResolvedType
getParentClass()
Returns parent class of this type, if it has one; primitive types and interfaces have no parent class, nor does Object typeObject
.abstract ResolvedType
getSelfReferencedType()
Accessor that must be used to find out actual type in case of "self-reference"; case where type refers recursive to itself (like,T implements Comparable<T>
).String
getSignature()
Method that returns full generic signature of the type; suitable as signature for things like ASM package.List<RawField>
getStaticFields()
List<RawMethod>
getStaticMethods()
TypeBindings
getTypeBindings()
Method for accessing bindings of type variables to resolved types in context of this type.List<ResolvedType>
getTypeParameters()
Returns list of generic type declarations for this type, in order they are declared in class description.int
hashCode()
abstract boolean
isAbstract()
abstract boolean
isArray()
Method that indicates whether this type is an array type.boolean
isConcrete()
boolean
isInstanceOf(Class<?> type)
abstract boolean
isInterface()
abstract boolean
isPrimitive()
Method that indicates whether this type is one of small number of primitive Java types; not including array types of primitive types but just basic primitive types.String
toString()
List<ResolvedType>
typeParametersFor(Class<?> erasedSupertype)
Method that will try to find type parameterization this type has for specified super type-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.reflect.Type
getTypeName
-
-
-
-
Field Detail
-
NO_TYPES
public static final ResolvedType[] NO_TYPES
-
NO_CONSTRUCTORS
protected static final RawConstructor[] NO_CONSTRUCTORS
-
NO_FIELDS
protected static final RawField[] NO_FIELDS
-
NO_METHODS
protected static final RawMethod[] NO_METHODS
-
_erasedType
protected final Class<?> _erasedType
-
_typeBindings
protected final TypeBindings _typeBindings
Type bindings active when resolving members (methods, fields, constructors) of this type
-
-
Constructor Detail
-
ResolvedType
protected ResolvedType(Class<?> cls, TypeBindings bindings)
-
-
Method Detail
-
canCreateSubtypes
public abstract boolean canCreateSubtypes()
Method that can be used to check if call toTypeResolver.resolveSubtype(ResolvedType, Class)
may ever succeed; if false, it will fail with an exception, if true, it may succeed.
-
canCreateSubtype
public final boolean canCreateSubtype(Class<?> subtype)
Method that can be used to check if call toTypeResolver.resolveSubtype(ResolvedType, Class)
will succeed for specific type; if false, it will fail with an exception; if tru it will succeed.
-
getErasedType
public Class<?> getErasedType()
Returns type-erased Class<?> that this resolved type has.
-
getParentClass
public abstract ResolvedType getParentClass()
Returns parent class of this type, if it has one; primitive types and interfaces have no parent class, nor does Object typeObject
. Also, placeholders for cyclic (recursive) types return null for this method.
-
getSelfReferencedType
public abstract ResolvedType getSelfReferencedType()
Accessor that must be used to find out actual type in case of "self-reference"; case where type refers recursive to itself (like,T implements Comparable<T>
). For all other types returns null but for self-references "real" type. Separate accessor is provided to avoid accidental infinite loops.
-
getArrayElementType
public abstract ResolvedType getArrayElementType()
Method that can be used to access element type of array types; will return null for non-array types, and non-null type for array types.
-
getImplementedInterfaces
public abstract List<ResolvedType> getImplementedInterfaces()
Returns ordered list of interfaces (in declaration order) that this type implements.- Returns:
- List of interfaces this type implements, if any; empty list if none
-
getTypeParameters
public List<ResolvedType> getTypeParameters()
Returns list of generic type declarations for this type, in order they are declared in class description.
-
getTypeBindings
public TypeBindings getTypeBindings()
Method for accessing bindings of type variables to resolved types in context of this type. It has same number of entries as return List ofgetTypeParameters()
, accessible using declared name to which they bind; for example,Map
has 2 type bindings; one for key type (name "K", from Map.java) and one for value type (name "V", from Map.java).
-
typeParametersFor
public List<ResolvedType> typeParametersFor(Class<?> erasedSupertype)
Method that will try to find type parameterization this type has for specified super type- Returns:
- List of type parameters for specified supertype (which may be empty, if supertype is not a parametric type); null if specified type is not a super type of this type
-
findSupertype
public ResolvedType findSupertype(Class<?> erasedSupertype)
Method for finding super type of this type that has specified type erased signature. If supertype is an interface which is implemented using multiple inheritance paths, preference is given to interfaces implemented "highest up the stack" (directly implemented interfaces over interfaces superclass implements).
-
isInterface
public abstract boolean isInterface()
-
isConcrete
public final boolean isConcrete()
-
isAbstract
public abstract boolean isAbstract()
-
isArray
public abstract boolean isArray()
Method that indicates whether this type is an array type.
-
isPrimitive
public abstract boolean isPrimitive()
Method that indicates whether this type is one of small number of primitive Java types; not including array types of primitive types but just basic primitive types.
-
isInstanceOf
public final boolean isInstanceOf(Class<?> type)
-
getConstructors
public List<RawConstructor> getConstructors()
-
getSignature
public String getSignature()
Method that returns full generic signature of the type; suitable as signature for things like ASM package.
-
getErasedSignature
public String getErasedSignature()
Method that returns type erased signature of the type; suitable as non-generic signature some packages need
-
getFullDescription
public String getFullDescription()
Human-readable full description of type, which includes specification of super types (in brief format)
-
getBriefDescription
public String getBriefDescription()
Human-readable brief description of type, which does not include information about super types.
-
appendBriefDescription
public abstract StringBuilder appendBriefDescription(StringBuilder sb)
-
appendFullDescription
public abstract StringBuilder appendFullDescription(StringBuilder sb)
-
appendSignature
public abstract StringBuilder appendSignature(StringBuilder sb)
-
appendErasedSignature
public abstract StringBuilder appendErasedSignature(StringBuilder sb)
-
_appendClassSignature
protected StringBuilder _appendClassSignature(StringBuilder sb)
-
_appendErasedClassSignature
protected StringBuilder _appendErasedClassSignature(StringBuilder sb)
-
_appendClassDescription
protected StringBuilder _appendClassDescription(StringBuilder sb)
-
_appendClassName
protected StringBuilder _appendClassName(StringBuilder sb)
-
_getFields
protected RawField[] _getFields(boolean statics)
- Parameters:
statics
- Whether to return static methods (true) or member methods (false)
-
_getMethods
protected RawMethod[] _getMethods(boolean statics)
- Parameters:
statics
- Whether to return static methods (true) or member methods (false)
-
_getConstructors
protected RawConstructor[] _getConstructors()
-
-