Package spoon.support.reflect.reference
Class CtTypeParameterReferenceImpl
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.reference.CtReferenceImpl
spoon.support.reflect.reference.CtTypeReferenceImpl<Object>
spoon.support.reflect.reference.CtTypeParameterReferenceImpl
- All Implemented Interfaces:
Serializable
,Cloneable
,FactoryAccessor
,SourcePositionHolder
,CtElement
,CtShadowable
,CtTypeInformation
,CtActualTypeContainer
,CtReference
,CtTypeParameterReference
,CtTypeReference<Object>
,CtQueryable
,CtVisitable
- Direct Known Subclasses:
CtWildcardReferenceImpl
public class CtTypeParameterReferenceImpl
extends CtTypeReferenceImpl<Object>
implements CtTypeParameterReference
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class spoon.support.reflect.reference.CtReferenceImpl
simplename
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parent
Fields inherited from interface spoon.reflect.reference.CtTypeReference
NULL_TYPE_NAME, OMITTED_TYPE_ARG_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts a visitor<C extends CtActualTypeContainer>
CaddActualTypeArgument(CtTypeReference<?> actualTypeArgument)
Adds a type argument.clone()
Clone the element which calls this method in a new object.protected AnnotatedElement
Gets the Java runtime class of the referenced type.List<CtTypeReference<?>>
Gets the type arguments.A type parameter can have anextends
clause which declare one (CtTypeReference
or more (CtIntersectionTypeReference
references.Returns theCtType
, that corresponds to the reference ornull
if the type declaration is not in the analyzed source files,CtTypeReference.getTypeDeclaration()
is a newer and better alternative that less often returns null.Returns theCtType
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, seeCtShadowable.isShadow()
).This method returns a reference to the erased type.boolean
Returns true if this has the default bounding type that is java.lang.Object (which basically means that there is no bound)boolean
Returns true if it is not a concrete, resolvable class, it if refers to a type parameter directly or indirectly.boolean
Checks if the referenced type is a primitive type.boolean
boolean
isSubtypeOf(CtTypeReference<?> type)
Checks if this type is a subtype of the given type.protected boolean
boolean
removeActualTypeArgument(CtTypeReference<?> actualTypeArgument)
Removes a type argument.<C extends CtActualTypeContainer>
CsetActualTypeArguments(List<? extends CtTypeReference<?>> actualTypeArguments)
Sets the type arguments.setSimplyQualified(boolean isSimplyQualified)
Methods inherited from class spoon.support.reflect.reference.CtTypeReferenceImpl
asCtIntersectionTypeReference, box, canAccess, canAccess, findClass, getAccessType, getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getDeclaringType, getModifiers, getPackage, getQualifiedName, getSuperclass, getSuperInterfaces, getTopLevelType, getTypeParameterDeclaration, isAnnotationType, isAnonymous, isArray, isClass, isEnum, isInterface, isLocalType, isParameterized, isShadow, setDeclaringType, setPackage, setShadow, unbox
Methods inherited from class spoon.support.reflect.reference.CtReferenceImpl
equals, getSimpleName, setComments, setSimpleName
Methods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, filterChildren, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getFactory, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hashCode, hasParent, isImplicit, isParentInitialized, map, map, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setDocComment, setFactory, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, unmodifiableList, updateAllParentsBelow
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.reference.CtReference
setComments, setSimpleName
Methods inherited from interface spoon.reflect.declaration.CtShadowable
isShadow, setShadow
Methods inherited from interface spoon.reflect.declaration.CtTypeInformation
getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getQualifiedName, isAnnotationType, isAnonymous, isArray, isClass, isEnum, isInterface, isLocalType, isParameterized
Methods inherited from interface spoon.reflect.reference.CtTypeReference
asCtIntersectionTypeReference, box, canAccess, canAccess, getAccessType, getDeclaringType, getModifiers, getPackage, getSimpleName, getSuperclass, getSuperInterfaces, getTopLevelType, getTypeParameterDeclaration, setDeclaringType, setPackage, unbox
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtTypeParameterReferenceImpl
public CtTypeParameterReferenceImpl()
-
-
Method Details
-
isDefaultBoundingType
public boolean isDefaultBoundingType()Description copied from interface:CtTypeParameterReference
Returns true if this has the default bounding type that is java.lang.Object (which basically means that there is no bound)- Specified by:
isDefaultBoundingType
in interfaceCtTypeParameterReference
-
accept
Description copied from interface:CtVisitable
Accepts a visitor- Specified by:
accept
in interfaceCtVisitable
- Overrides:
accept
in classCtTypeReferenceImpl<Object>
-
isPrimitive
public boolean isPrimitive()Description copied from interface:CtTypeInformation
Checks if the referenced type is a primitive type.It is a primitive type, if it is one of the following types:
- byte
- short
- int
- long
- float
- double
- boolean
- char
- void
For boxed types like
Integer
this method returnsfalse
.- Specified by:
isPrimitive
in interfaceCtTypeInformation
- Overrides:
isPrimitive
in classCtTypeReferenceImpl<Object>
- Returns:
true
if the referenced type is a primitive type
-
getActualClass
Description copied from interface:CtTypeReference
Gets the Java runtime class of the referenced type. This is a low-level feature, it should never been used, useCtTypeReference.getTypeDeclaration()
instead in order to only stay in the Spoon world and manipulate CtType instead of java.lang.Class.
Note (these are artifacts of the current implementation and might change at any time):-
it will return the version of the class your
Environment.getInputClassLoader()
loads. This might be a version spoon compiled (manually usingSpoonModelBuilder.compile(spoon.SpoonModelBuilder.InputType...)
or implicitly usingEnvironment.shouldCompile()
) or from your classpath (which might be null) - it will run static initializers (executing arbitrary code from the analyzed project in the process)
- it will fail if the static initializers of the class fail
- the Class object may not reflect the CtType in case you made recent changes to it based on point 1
- Specified by:
getActualClass
in interfaceCtTypeReference<Object>
- Overrides:
getActualClass
in classCtTypeReferenceImpl<Object>
- Returns:
- the Java class or throws a
SpoonClassNotFoundException
if the class is not found.
-
it will return the version of the class your
-
getActualTypeArguments
Description copied from interface:CtActualTypeContainer
Gets the type arguments.- Specified by:
getActualTypeArguments
in interfaceCtActualTypeContainer
- Overrides:
getActualTypeArguments
in classCtTypeReferenceImpl<Object>
-
setActualTypeArguments
public <C extends CtActualTypeContainer> C setActualTypeArguments(List<? extends CtTypeReference<?>> actualTypeArguments)Description copied from interface:CtActualTypeContainer
Sets the type arguments.- Specified by:
setActualTypeArguments
in interfaceCtActualTypeContainer
- Specified by:
setActualTypeArguments
in interfaceCtTypeParameterReference
- Overrides:
setActualTypeArguments
in classCtTypeReferenceImpl<Object>
-
addActualTypeArgument
public <C extends CtActualTypeContainer> C addActualTypeArgument(CtTypeReference<?> actualTypeArgument)Description copied from interface:CtActualTypeContainer
Adds a type argument.- Specified by:
addActualTypeArgument
in interfaceCtActualTypeContainer
- Overrides:
addActualTypeArgument
in classCtTypeReferenceImpl<Object>
-
removeActualTypeArgument
Description copied from interface:CtActualTypeContainer
Removes a type argument.- Specified by:
removeActualTypeArgument
in interfaceCtActualTypeContainer
- Overrides:
removeActualTypeArgument
in classCtTypeReferenceImpl<Object>
-
getBoundingType
Description copied from interface:CtTypeParameterReference
A type parameter can have anextends
clause which declare one (CtTypeReference
or more (CtIntersectionTypeReference
references.// Extends with generics. T extends Interface1 // Intersection type with generics. T extends Interface1 & Interface2
- Specified by:
getBoundingType
in interfaceCtTypeParameterReference
-
getActualAnnotatedElement
- Overrides:
getActualAnnotatedElement
in classCtTypeReferenceImpl<Object>
-
getDeclaration
Description copied from interface:CtTypeReference
Returns theCtType
, that corresponds to the reference ornull
if the type declaration is not in the analyzed source files,CtTypeReference.getTypeDeclaration()
is a newer and better alternative that less often returns null.- Specified by:
getDeclaration
in interfaceCtReference
- Specified by:
getDeclaration
in interfaceCtTypeParameterReference
- Specified by:
getDeclaration
in interfaceCtTypeReference<Object>
- Overrides:
getDeclaration
in classCtTypeReferenceImpl<Object>
- Returns:
- the referenced element or
null
if the type declaration is not the analyzed source files.
-
getTypeDeclaration
Description copied from interface:CtTypeReference
Returns theCtType
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, seeCtShadowable.isShadow()
).- Specified by:
getTypeDeclaration
in interfaceCtTypeReference<Object>
- Overrides:
getTypeDeclaration
in classCtTypeReferenceImpl<Object>
- Returns:
- the type declaration that corresponds to the reference or null if the reference points to a class that is not in the classpath.
-
getTypeErasure
Description copied from interface:CtTypeInformation
This method returns a reference to the erased type.For example, this will return
List
forList<String>
, orEnum
for the type parameterE
in the enum declaration.- Specified by:
getTypeErasure
in interfaceCtTypeInformation
- Overrides:
getTypeErasure
in classCtTypeReferenceImpl<Object>
- Returns:
- a reference to the erased type
- See Also:
- Type Erasure
-
isSubtypeOf
Description copied from interface:CtTypeInformation
Checks if this type is a subtype of the given type.- Specified by:
isSubtypeOf
in interfaceCtTypeInformation
- Overrides:
isSubtypeOf
in classCtTypeReferenceImpl<Object>
- Parameters:
type
- the type that might be a parent of this type.- Returns:
true
if the referenced type is a subtype of the given type, otherwisefalse
. If this type is the same as the given type (typeX.isSubtypeOf(typeX)
), this method returnstrue
.
-
clone
Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtReference
- Specified by:
clone
in interfaceCtTypeParameterReference
- Specified by:
clone
in interfaceCtTypeReference<Object>
- Overrides:
clone
in classCtTypeReferenceImpl<Object>
-
isGenerics
public boolean isGenerics()Description copied from interface:CtTypeInformation
Returns true if it is not a concrete, resolvable class, it if refers to a type parameter directly or indirectly. Direct: "T foo" isGenerics returns true. Indirect: List<T>, or Set<List<T>> isGenerics returns true- Specified by:
isGenerics
in interfaceCtTypeInformation
- Overrides:
isGenerics
in classCtTypeReferenceImpl<Object>
-
isWildcard
protected boolean isWildcard() -
isSimplyQualified
public boolean isSimplyQualified()- Specified by:
isSimplyQualified
in interfaceCtTypeReference<Object>
- Overrides:
isSimplyQualified
in classCtTypeReferenceImpl<Object>
- Returns:
- false then fully qualified name is printed. true then type simple name is printed.
-
setSimplyQualified
- Specified by:
setSimplyQualified
in interfaceCtTypeReference<Object>
- Overrides:
setSimplyQualified
in classCtTypeReferenceImpl<Object>
- Parameters:
isSimplyQualified
- false then the reference is printed fully qualified name. true then only the type name is printed.
-