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:
-
Field Summary
Fields inherited from class spoon.support.reflect.reference.CtReferenceImpl
simplenameFields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parentFields inherited from interface spoon.reflect.reference.CtTypeReference
NULL_TYPE_NAME, OMITTED_TYPE_ARG_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccepts 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 AnnotatedElementGets the Java runtime class of the referenced type.List<CtTypeReference<?>>Gets the type arguments.A type parameter can have anextendsclause which declare one (CtTypeReferenceor more (CtIntersectionTypeReferencereferences.Returns theCtType, that corresponds to the reference ornullif the type declaration is not in the analyzed source files,CtTypeReference.getTypeDeclaration()is a newer and better alternative that less often returns null.Returns theCtTypethat 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.booleanReturns true if this has the default bounding type that is java.lang.Object (which basically means that there is no bound)booleanReturns true if it is not a concrete, resolvable class, it if refers to a type parameter directly or indirectly.booleanChecks if the referenced type is a primitive type.booleanbooleanisSubtypeOf(CtTypeReference<?> type) Checks if this type is a subtype of the given type.protected booleanbooleanremoveActualTypeArgument(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, unboxMethods inherited from class spoon.support.reflect.reference.CtReferenceImpl
equals, getSimpleName, setComments, setSimpleNameMethods 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, updateAllParentsBelowMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, updateAllParentsBelowMethods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, mapMethods inherited from interface spoon.reflect.reference.CtReference
setComments, setSimpleNameMethods inherited from interface spoon.reflect.declaration.CtShadowable
isShadow, setShadowMethods inherited from interface spoon.reflect.declaration.CtTypeInformation
getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getQualifiedName, isAnnotationType, isAnonymous, isArray, isClass, isEnum, isInterface, isLocalType, isParameterizedMethods inherited from interface spoon.reflect.reference.CtTypeReference
asCtIntersectionTypeReference, box, canAccess, canAccess, getAccessType, getDeclaringType, getModifiers, getPackage, getSimpleName, getSuperclass, getSuperInterfaces, getTopLevelType, getTypeParameterDeclaration, setDeclaringType, setPackage, unboxMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtTypeParameterReferenceImpl
public CtTypeParameterReferenceImpl()
-
-
Method Details
-
isDefaultBoundingType
public boolean isDefaultBoundingType()Description copied from interface:CtTypeParameterReferenceReturns true if this has the default bounding type that is java.lang.Object (which basically means that there is no bound)- Specified by:
isDefaultBoundingTypein interfaceCtTypeParameterReference
-
accept
Description copied from interface:CtVisitableAccepts a visitor- Specified by:
acceptin interfaceCtVisitable- Overrides:
acceptin classCtTypeReferenceImpl<Object>
-
isPrimitive
public boolean isPrimitive()Description copied from interface:CtTypeInformationChecks 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
Integerthis method returnsfalse.- Specified by:
isPrimitivein interfaceCtTypeInformation- Overrides:
isPrimitivein classCtTypeReferenceImpl<Object>- Returns:
trueif the referenced type is a primitive type
-
getActualClass
Description copied from interface:CtTypeReferenceGets 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:
getActualClassin interfaceCtTypeReference<Object>- Overrides:
getActualClassin classCtTypeReferenceImpl<Object>- Returns:
- the Java class or throws a
SpoonClassNotFoundExceptionif the class is not found.
-
it will return the version of the class your
-
getActualTypeArguments
Description copied from interface:CtActualTypeContainerGets the type arguments.- Specified by:
getActualTypeArgumentsin interfaceCtActualTypeContainer- Overrides:
getActualTypeArgumentsin classCtTypeReferenceImpl<Object>
-
setActualTypeArguments
public <C extends CtActualTypeContainer> C setActualTypeArguments(List<? extends CtTypeReference<?>> actualTypeArguments) Description copied from interface:CtActualTypeContainerSets the type arguments.- Specified by:
setActualTypeArgumentsin interfaceCtActualTypeContainer- Specified by:
setActualTypeArgumentsin interfaceCtTypeParameterReference- Overrides:
setActualTypeArgumentsin classCtTypeReferenceImpl<Object>
-
addActualTypeArgument
public <C extends CtActualTypeContainer> C addActualTypeArgument(CtTypeReference<?> actualTypeArgument) Description copied from interface:CtActualTypeContainerAdds a type argument.- Specified by:
addActualTypeArgumentin interfaceCtActualTypeContainer- Overrides:
addActualTypeArgumentin classCtTypeReferenceImpl<Object>
-
removeActualTypeArgument
Description copied from interface:CtActualTypeContainerRemoves a type argument.- Specified by:
removeActualTypeArgumentin interfaceCtActualTypeContainer- Overrides:
removeActualTypeArgumentin classCtTypeReferenceImpl<Object>
-
getBoundingType
Description copied from interface:CtTypeParameterReferenceA type parameter can have anextendsclause which declare one (CtTypeReferenceor more (CtIntersectionTypeReferencereferences.// Extends with generics. T extends Interface1 // Intersection type with generics. T extends Interface1 & Interface2- Specified by:
getBoundingTypein interfaceCtTypeParameterReference
-
getActualAnnotatedElement
- Overrides:
getActualAnnotatedElementin classCtTypeReferenceImpl<Object>
-
getDeclaration
Description copied from interface:CtTypeReferenceReturns theCtType, that corresponds to the reference ornullif 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:
getDeclarationin interfaceCtReference- Specified by:
getDeclarationin interfaceCtTypeParameterReference- Specified by:
getDeclarationin interfaceCtTypeReference<Object>- Overrides:
getDeclarationin classCtTypeReferenceImpl<Object>- Returns:
- the referenced element or
nullif the type declaration is not the analyzed source files.
-
getTypeDeclaration
Description copied from interface:CtTypeReferenceReturns theCtTypethat 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:
getTypeDeclarationin interfaceCtTypeReference<Object>- Overrides:
getTypeDeclarationin 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:CtTypeInformationThis method returns a reference to the erased type.For example, this will return
ListforList<String>, orEnumfor the type parameterEin the enum declaration.- Specified by:
getTypeErasurein interfaceCtTypeInformation- Overrides:
getTypeErasurein classCtTypeReferenceImpl<Object>- Returns:
- a reference to the erased type
- See Also:
-
isSubtypeOf
Description copied from interface:CtTypeInformationChecks if this type is a subtype of the given type.- Specified by:
isSubtypeOfin interfaceCtTypeInformation- Overrides:
isSubtypeOfin classCtTypeReferenceImpl<Object>- Parameters:
type- the type that might be a parent of this type.- Returns:
trueif 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:CtElementClone 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:
clonein interfaceCtElement- Specified by:
clonein interfaceCtReference- Specified by:
clonein interfaceCtTypeParameterReference- Specified by:
clonein interfaceCtTypeReference<Object>- Overrides:
clonein classCtTypeReferenceImpl<Object>- Returns:
- a clone of this element. All children are cloned, but the parent of the returned clone is set to null.
-
isGenerics
public boolean isGenerics()Description copied from interface:CtTypeInformationReturns 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:
isGenericsin interfaceCtTypeInformation- Overrides:
isGenericsin classCtTypeReferenceImpl<Object>
-
isWildcard
protected boolean isWildcard() -
isSimplyQualified
public boolean isSimplyQualified()- Specified by:
isSimplyQualifiedin interfaceCtTypeReference<Object>- Overrides:
isSimplyQualifiedin classCtTypeReferenceImpl<Object>- Returns:
- false then fully qualified name is printed. true then type simple name is printed.
-
setSimplyQualified
- Specified by:
setSimplyQualifiedin interfaceCtTypeReference<Object>- Overrides:
setSimplyQualifiedin classCtTypeReferenceImpl<Object>- Parameters:
isSimplyQualified- false then the reference is printed fully qualified name. true then only the type name is printed.
-