public interface CtTypeReference<T> extends CtReference, CtActualTypeContainer, CtTypeInformation, CtShadowable
CtType
or sub-type.Modifier and Type | Field and Description |
---|---|
static String |
NULL_TYPE_NAME
The name of the null type ("<nulltype>").
|
Modifier and Type | Method and Description |
---|---|
CtIntersectionTypeReference<T> |
asCtIntersectionTypeReference()
Casts the type reference in
CtIntersectionTypeReference . |
CtTypeReference<?> |
box()
Returns the corresponding non-primitive type for a primitive type (the
same type otherwise).
|
boolean |
canAccess(CtTypeMember typeMember) |
boolean |
canAccess(CtTypeReference<?> type)
Checks visibility based on public, protected, package protected and private modifiers of type
|
CtTypeReference<T> |
clone()
Clone the element which calls this method in a new object.
|
CtTypeReference<?> |
getAccessType()
Computes nearest access path parent to this type from the context of this type reference.
|
Class<T> |
getActualClass()
Deprecated.
(Since Spoon 7.0.0) use
getTypeDeclaration() instead |
CtType<T> |
getDeclaration()
Returns the
CtType , that corresponds to the
reference or null if the type declaration is not in the
analyzed source files,
getTypeDeclaration() is a newer and better alternative that never returns null. |
CtTypeReference<?> |
getDeclaringType()
Gets the type that declares the referenced type.
|
Set<ModifierKind> |
getModifiers()
Gets modifiers of this type.
|
CtPackageReference |
getPackage()
Gets the package of the referenced type.
|
String |
getSimpleName()
Returns the simple (unqualified) name of this element.
|
CtTypeReference<?> |
getSuperclass()
Returns the class type directly extended by this class.
|
Set<CtTypeReference<?>> |
getSuperInterfaces()
Returns the interface types directly implemented by this class or
extended by this interface.
|
CtTypeReference<?> |
getTopLevelType()
Returns this, or top level type of this, if this is an inner type
|
CtType<T> |
getTypeDeclaration()
Returns the
CtType that corresponds to the reference even if the
type isn't in the Spoon source path (in this case, the Spoon elements are
built with runtime reflection, and the resulting CtType is called a "shadow" class,
see CtShadowable.isShadow() ). |
CtTypeParameter |
getTypeParameterDeclaration()
If this type reference is used as a type argument (see
CtActualTypeContainer.getActualTypeArguments() ), returns the type parameter declaration in the target type, returns null otherwise. |
boolean |
isImplicitParent() |
<C extends CtTypeReference<T>> |
setDeclaringType(CtTypeReference<?> type)
Sets the reference to the declaring type.
|
CtTypeReference<T> |
setImplicitParent(boolean parentIsImplicit) |
<C extends CtTypeReference<T>> |
setPackage(CtPackageReference pack)
Sets the reference to the declaring package.
|
CtTypeReference<?> |
unbox()
Returns the primitive type for a boxing type (unchanged if the type does
not correspond to a boxing type).
|
setComments, setSimpleName
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, updateAllParentsBelow
getFactory, setFactory
accept
filterChildren, map, map
getOriginalSourceFragment
addActualTypeArgument, getActualTypeArguments, removeActualTypeArgument, setActualTypeArguments
getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getQualifiedName, getTypeErasure, isAnnotationType, isAnonymous, isArray, isClass, isEnum, isGenerics, isInterface, isLocalType, isPrimitive, isSubtypeOf
isShadow, setShadow
static final String NULL_TYPE_NAME
String getSimpleName()
getSimpleName
in interface CtReference
Class<T> getActualClass()
getTypeDeclaration()
insteadgetTypeDeclaration()
instead,
in order to only stay in the Spoon world and manipulate CtType instead of java.lang.Class.SpoonClassNotFoundException
if the class is not found.SpoonClassNotFoundException
- if the class is not in the classpathCtType<T> getDeclaration()
CtType
, that corresponds to the
reference or null
if the type declaration is not in the
analyzed source files,
getTypeDeclaration()
is a newer and better alternative that never returns null.getDeclaration
in interface CtReference
null
if the type
declaration is not the analyzed source files.CtType<T> getTypeDeclaration()
CtType
that corresponds to the reference even if the
type isn't in the Spoon source path (in this case, the Spoon elements are
built with runtime reflection, and the resulting CtType is called a "shadow" class,
see CtShadowable.isShadow()
).CtTypeReference<?> getDeclaringType()
CtPackageReference getPackage()
CtTypeReference<?> box()
CtTypeReference<?> unbox()
<C extends CtTypeReference<T>> C setDeclaringType(CtTypeReference<?> type)
<C extends CtTypeReference<T>> C setPackage(CtPackageReference pack)
CtIntersectionTypeReference<T> asCtIntersectionTypeReference()
CtIntersectionTypeReference
.CtTypeReference<T> clone()
CtElement
Refactoring.copyType(CtType)
and Refactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.clone
in interface CtElement
clone
in interface CtReference
Set<CtTypeReference<?>> getSuperInterfaces()
CtTypeInformation
getSuperInterfaces
in interface CtTypeInformation
CtTypeReference<?> getSuperclass()
CtTypeInformation
getSuperclass
in interface CtTypeInformation
Set<ModifierKind> getModifiers()
CtTypeInformation
getModifiers
in interface CtTypeInformation
boolean canAccess(CtTypeReference<?> type)
type
- boolean canAccess(CtTypeMember typeMember)
CtTypeReference<?> getTopLevelType()
CtTypeReference<?> getAccessType()
class A { class B { class C {} } }The C.getAccessParentFrom(null) will return B, because B can be used to access C, using code like
B.C
protected
:
class D extends B { } class X extends D { class F extends C }The C.getAccessParentFrom(X) will return D, because D can be used to access C in scope of X.
CtTypeParameter getTypeParameterDeclaration()
CtActualTypeContainer.getActualTypeArguments()
), returns the type parameter declaration in the target type, returns null otherwise.
In the following example, getTypeParameterDeclaration of "String" returns the type parameter definition "X".
class Dog<X>{} Dog<String>var = ...;In this other example, getTypeParameterDeclaration of T in Dog<T> returns the type parameter definition "X" (while
getDeclaration()
returns the "T" of Cat).
class Dog<X>{} class Cat<T> { Dog<T> dog; }
CtTypeReference<T> setImplicitParent(boolean parentIsImplicit)
parentIsImplicit
- false then fully qualified name is printed.
true then type simple name is printed.boolean isImplicitParent()
Copyright © 2007–2019 Inria. All rights reserved.