Class CtTypeImpl<T>
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.declaration.CtNamedElementImpl
spoon.support.reflect.declaration.CtTypeImpl<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,FactoryAccessor
,SourcePositionHolder
,CtElement
,CtFormalTypeDeclarer
,CtModifiable
,CtNamedElement
,CtShadowable
,CtType<T>
,CtTypeInformation
,CtTypeMember
,CtQueryable
,CtVisitable
- Direct Known Subclasses:
CtAnnotationTypeImpl
,CtClassImpl
,CtInterfaceImpl
,CtTypeParameterImpl
The implementation for
CtType
.- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parent
Fields inherited from interface spoon.reflect.declaration.CtType
INNERTTYPE_SEPARATOR, NAME_UNKNOWN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd a field at a given position.add a field at the end of the field list.addFieldAtTop(CtField<F> field)
Adds a field at the top of the type (before static block).<C extends CtFormalTypeDeclarer>
CaddFormalCtTypeParameter(CtTypeParameter formalTypeParameter)
Add a type parameter to this generic element.<C extends CtFormalTypeDeclarer>
CaddFormalCtTypeParameterAt(int position, CtTypeParameter formalTypeParameter)
Add a type parameter at a specific position.Adds a method to this type.<C extends CtModifiable>
CaddModifier(ModifierKind modifier)
add a modifieraddNestedType(CtType<N> nestedType)
Add a nested type.addSuperInterface(CtTypeReference<S> interfac)
addTypeMember(CtTypeMember member)
Adds a type member.addTypeMemberAt(int position, CtTypeMember member)
Adds a type member at a given position.clone()
Clone the element which calls this method in a new object.void
Replace all the code snippets that are found in this type by the corresponding Spoon AST.CtType<?>
copyType()
Copy the type, where copy means cloning + porting all the references in the clone from the old type to the new type.This is a low-level feature, it should never been used by non advanced users.Gets the executables declared by this type and by all its supertypes (static/instance methods, constructors, anonymous static blocks) if applicable.List<CtFieldReference<?>>
Gets the fields declared by this type and by all its supertypes if applicable.Return all the methods that can be called on an instance of this type.Gets the executables declared by this type if applicable.getDeclaredField(String name)
Gets a field from its name.List<CtFieldReference<?>>
Gets the fields declared by this type.getDeclaredOrInheritedField(String fieldName)
Gets a field from this type or any super type or any implemented interface by field name.CtType<?>
Gets the type that declares this class member.CtField<?>
Gets a field from its name.Returns the fields that are directly declared by this class or interface.Returns the formal type parameters of this generic element.<R> CtMethod<R>
getMethod(String name, CtTypeReference<?>... parameterTypes)
Gets a method from its name and parameter types.<R> CtMethod<R>
getMethod(CtTypeReference<R> returnType, String name, CtTypeReference<?>... parameterTypes)
Gets a method from its return type, name, and parameter types.Returns the methods that are directly declared by this class or interface.getMethodsAnnotatedWith(CtTypeReference<?>... annotationTypes)
Returns the methods that are directly declared by this class or interface and annotated with one of the given annotations.getMethodsByName(String name)
Returns the methods that are directly declared by this class or interface and that have the given name.Gets modifiers of this type.<N extends CtType<?>>
NgetNestedType(String name)
Gets a nested type from its name.Returns the declarations of the nested classes and interfaces that are directly declared by this class or interface.Gets the package where this type is declared.Returns the fully qualified name of this type declaration.Returns the corresponding reference.Returns a reference to the type directly extended by this type.Set<CtTypeReference<?>>
Returns the interface types directly implemented by this class or extended by this interface.<T> CtType<T>
Returns the top level type declaring this type if an inner type or type member.This method returns a reference to the erased type.Gets all type members of the type like fields, methods, anonymous block, etc.Set<CtTypeReference<?>>
getUsedTypes(boolean includeSamePackage)
Returns the types used by this type.Gets the visibility of this modifiable element.boolean
Searches in the type for the given method.boolean
hasModifier(ModifierKind modifier)
Tells if this element contains the given modifier.protected boolean
hasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes)
boolean
Returns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if this type is an annotation type.boolean
Returntrue
if the referenced type is an anonymous typeboolean
isArray()
Returns true if this type represents an array likeObject[]
orint[]
.boolean
isClass()
Returns true if this type is a class.boolean
isEnum()
Returns true if this type is an enum.boolean
isFinal()
Returns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it is not a concrete, resolvable class, it if refers to a type parameter directly or indirectly.boolean
Returns true if this type is an interface.boolean
Returnstrue
if the referenced type is declared in an executable.boolean
isNative()
Returns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it has any type parameter (generic or not).boolean
Checks if the referenced type is a primitive type.boolean
Returns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
isPublic()
Returns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
isShadow()
When an element isn't present in the factory (created in another factory), this element is considered as "shadow".boolean
isStatic()
Returns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if this type is top-level (declared as the main type in a file).boolean
Returns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind)
)boolean
Returns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind)
)<F> boolean
removeField(CtField<F> field)
remove a Fieldboolean
removeFormalCtTypeParameter(CtTypeParameter formalTypeParameter)
Removes a type parameters from this generic element.<M> boolean
removeMethod(CtMethod<M> method)
Removes a method from this type.<C extends CtModifiable>
CremoveModifier(ModifierKind modifier)
remove a modifier<N> boolean
removeNestedType(CtType<N> nestedType)
Remove a nested type.<S> boolean
removeSuperInterface(CtTypeReference<S> interfac)
boolean
removeTypeMember(CtTypeMember member)
Removes the type member.<T extends CtModifiable>
TsetExtendedModifiers(Set<CtExtendedModifier> extendedModifiers)
Sets all fields in the type.<C extends CtFormalTypeDeclarer>
CsetFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters)
Sets the type parameters of this generic element.setMethods(Set<CtMethod<?>> methods)
Sets the methods of this type.<C extends CtModifiable>
CsetModifiers(Set<ModifierKind> modifiers)
Sets the modifiers.setNestedTypes(Set<CtType<?>> nestedTypes)
Sets all nested types.<E extends CtShadowable>
EsetShadow(boolean isShadow)
Marks an element as shadow.<T extends CtNamedElement>
TsetSimpleName(String simpleName)
Sets the simple (unqualified) name of this element.setSuperclass(CtTypeReference<?> superClass)
Sets the superclass type.setSuperInterfaces(Set<CtTypeReference<?>> interfaces)
Sets the super interfaces of this type.setTypeMembers(List<CtTypeMember> members)
Removes all types members with these new members.<C extends CtModifiable>
CsetVisibility(ModifierKind visibility)
Sets the visibility of this modifiable element (replaces old visibility).Gets the entire class code with package and imports.Methods inherited from class spoon.support.reflect.declaration.CtNamedElementImpl
getSimpleName
Methods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, equals, 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, setComments, 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, setComments, 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.declaration.CtType
getSimpleName
Methods inherited from interface spoon.reflect.declaration.CtTypeInformation
isSubtypeOf
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtTypeImpl
protected CtTypeImpl()
-
-
Method Details
-
getTypeMembers
Description copied from interface:CtType
Gets all type members of the type like fields, methods, anonymous block, etc.- Specified by:
getTypeMembers
in interfaceCtType<T>
-
addTypeMember
Adds a type member. If it has a position, adds it at the right place according to the position (sourceStart). If it is implicit, adds it at the beginning. Otherwise, adds it at the end.- Specified by:
addTypeMember
in interfaceCtType<T>
-
addTypeMemberAt
Description copied from interface:CtType
Adds a type member at a given position. Think to use this method if the order is important for you.- Specified by:
addTypeMemberAt
in interfaceCtType<T>
-
removeTypeMember
Description copied from interface:CtType
Removes the type member.- Specified by:
removeTypeMember
in interfaceCtType<T>
-
setTypeMembers
Description copied from interface:CtType
Removes all types members with these new members.- Specified by:
setTypeMembers
in interfaceCtType<T>
-
addFieldAtTop
Description copied from interface:CtType
Adds a field at the top of the type (before static block). Note that the position of these field will be negative to be written at the top of the type.- Specified by:
addFieldAtTop
in interfaceCtType<T>
- Returns:
- true if the field is added.
-
addField
Description copied from interface:CtType
add a field at the end of the field list. -
addField
Description copied from interface:CtType
add a field at a given position. -
setFields
Description copied from interface:CtType
Sets all fields in the type. -
removeField
Description copied from interface:CtType
remove a Field- Specified by:
removeField
in interfaceCtType<T>
- Returns:
- true if this element changed as a result of the call
-
getField
Description copied from interface:CtType
Gets a field from its name. -
getDeclaredField
Description copied from interface:CtTypeInformation
Gets a field from its name.- Specified by:
getDeclaredField
in interfaceCtTypeInformation
- Returns:
- a reference to the field with the name or
null
if it does not exist
-
getDeclaredOrInheritedField
Description copied from interface:CtTypeInformation
Gets a field from this type or any super type or any implemented interface by field name.- Specified by:
getDeclaredOrInheritedField
in interfaceCtTypeInformation
- Returns:
- a reference to the field with the name or
null
if it does not exist
-
getFields
Description copied from interface:CtType
Returns the fields that are directly declared by this class or interface. Includes enum constants. Derived fromCtType.getTypeMembers()
-
addNestedType
Description copied from interface:CtType
Add a nested type.- Specified by:
addNestedType
in interfaceCtType<T>
- Returns:
- true if this element changed as a result of the call
-
removeNestedType
Description copied from interface:CtType
Remove a nested type.- Specified by:
removeNestedType
in interfaceCtType<T>
- Returns:
- true if this element changed as a result of the call
-
setNestedTypes
Description copied from interface:CtType
Sets all nested types.- Specified by:
setNestedTypes
in interfaceCtType<T>
-
getUsedTypes
Description copied from interface:CtType
Returns the types used by this type.- Specified by:
getUsedTypes
in interfaceCtType<T>
- Parameters:
includeSamePackage
- set to true if the method should return also the types located in the same package as the current type
-
getActualClass
Description copied from interface:CtType
This is a low-level feature, it should never been used by non advanced users. See full documentation atCtTypeReference.getActualClass()
.- Specified by:
getActualClass
in interfaceCtType<T>
-
getDeclaringType
Description copied from interface:CtTypeMember
Gets the type that declares this class member.- Specified by:
getDeclaringType
in interfaceCtTypeMember
- Returns:
- declaring class
-
getTopLevelType
Description copied from interface:CtTypeMember
Returns the top level type declaring this type if an inner type or type member. If this is already a top-level type, then returns itself.- Specified by:
getTopLevelType
in interfaceCtTypeMember
-
getNestedType
Description copied from interface:CtType
Gets a nested type from its name.- Specified by:
getNestedType
in interfaceCtType<T>
-
getNestedTypes
Description copied from interface:CtType
Returns the declarations of the nested classes and interfaces that are directly declared by this class or interface.- Specified by:
getNestedTypes
in interfaceCtType<T>
-
getPackage
Description copied from interface:CtType
Gets the package where this type is declared.- Specified by:
getPackage
in interfaceCtType<T>
-
getReference
Description copied from interface:CtNamedElement
Returns the corresponding reference.- Specified by:
getReference
in interfaceCtNamedElement
- Specified by:
getReference
in interfaceCtType<T>
- Overrides:
getReference
in classCtNamedElementImpl
-
isTopLevel
public boolean isTopLevel()Description copied from interface:CtType
Returns true if this type is top-level (declared as the main type in a file).- Specified by:
isTopLevel
in interfaceCtType<T>
-
compileAndReplaceSnippets
public void compileAndReplaceSnippets()Description copied from interface:CtType
Replace all the code snippets that are found in this type by the corresponding Spoon AST.- Specified by:
compileAndReplaceSnippets
in interfaceCtType<T>
- See Also:
CtCodeSnippet
,CtCodeSnippetExpression
,CtCodeSnippetStatement
-
getModifiers
Description copied from interface:CtTypeInformation
Gets modifiers of this type.- Specified by:
getModifiers
in interfaceCtModifiable
- Specified by:
getModifiers
in interfaceCtTypeInformation
- Returns:
- the modifiers of this declaration in undefined order; an empty set if there are none
-
hasModifier
Description copied from interface:CtModifiable
Tells if this element contains the given modifier.- Specified by:
hasModifier
in interfaceCtModifiable
- Parameters:
modifier
- to search- Returns:
true
if this element contain the modifier
-
setModifiers
Description copied from interface:CtModifiable
Sets the modifiers.- Specified by:
setModifiers
in interfaceCtModifiable
-
addModifier
Description copied from interface:CtModifiable
add a modifier- Specified by:
addModifier
in interfaceCtModifiable
-
removeModifier
Description copied from interface:CtModifiable
remove a modifier- Specified by:
removeModifier
in interfaceCtModifiable
-
setVisibility
Description copied from interface:CtModifiable
Sets the visibility of this modifiable element (replaces old visibility).- Specified by:
setVisibility
in interfaceCtModifiable
-
getVisibility
Description copied from interface:CtModifiable
Gets the visibility of this modifiable element.- Specified by:
getVisibility
in interfaceCtModifiable
-
getExtendedModifiers
- Specified by:
getExtendedModifiers
in interfaceCtModifiable
- Returns:
- the set of extended modifiers (those incl. implicit).
-
setExtendedModifiers
- Specified by:
setExtendedModifiers
in interfaceCtModifiable
-
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
- Returns:
true
if the referenced type is a primitive type
-
isAnonymous
public boolean isAnonymous()Description copied from interface:CtTypeInformation
Returntrue
if the referenced type is an anonymous type- Specified by:
isAnonymous
in interfaceCtTypeInformation
-
isLocalType
public boolean isLocalType()Description copied from interface:CtTypeInformation
Returnstrue
if the referenced type is declared in an executable. e.g. a type declared in a method or a lambda. This corresponds toisLocalClass
ofjava.lang.Class
.// Type declared in a method. public void make() { class Cook { } } // Type declared in a lambda. s -> { class Cook { } }
- Specified by:
isLocalType
in interfaceCtTypeInformation
-
getSuperclass
Description copied from interface:CtTypeInformation
Returns a reference to the type directly extended by this type.To get the
CtType
of the super class, useCtTypeReference.getDeclaration()
orCtTypeReference.getTypeDeclaration()
on theCtTypeReference
returned by this method.- Specified by:
getSuperclass
in interfaceCtTypeInformation
- Returns:
- the type explicitly extended by this type, or
null
if there is none or if the super type is not in the classpath (in noclasspath mode). If a class does not explicitly extend another classnull
is returned (notObject
). For types like enums that implicitly extend a superclass likeEnum
, this method returns that class.
-
isClass
public boolean isClass()Description copied from interface:CtTypeInformation
Returns true if this type is a class. Returns false for others (enum, interface, generics, annotation).- Specified by:
isClass
in interfaceCtTypeInformation
-
isInterface
public boolean isInterface()Description copied from interface:CtTypeInformation
Returns true if this type is an interface.- Specified by:
isInterface
in interfaceCtTypeInformation
-
isAnnotationType
public boolean isAnnotationType()Description copied from interface:CtTypeInformation
Returns true if this type is an annotation type.- Specified by:
isAnnotationType
in interfaceCtTypeInformation
-
isEnum
public boolean isEnum()Description copied from interface:CtTypeInformation
Returns true if this type is an enum.- Specified by:
isEnum
in interfaceCtTypeInformation
-
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
-
isParameterized
public boolean isParameterized()Description copied from interface:CtTypeInformation
Returns true if it has any type parameter (generic or not).- Specified by:
isParameterized
in interfaceCtTypeInformation
-
getAllFields
Description copied from interface:CtTypeInformation
Gets the fields declared by this type and by all its supertypes if applicable.- Specified by:
getAllFields
in interfaceCtTypeInformation
-
getDeclaredFields
Description copied from interface:CtTypeInformation
Gets the fields declared by this type.- Specified by:
getDeclaredFields
in interfaceCtTypeInformation
-
addMethod
Description copied from interface:CtType
Adds a method to this type. -
removeMethod
Description copied from interface:CtType
Removes a method from this type.- Specified by:
removeMethod
in interfaceCtType<T>
-
addSuperInterface
- Specified by:
addSuperInterface
in interfaceCtType<T>
- Returns:
- true if this element changed as a result of the call
-
removeSuperInterface
- Specified by:
removeSuperInterface
in interfaceCtType<T>
- Returns:
- true if this element changed as a result of the call
-
getFormalCtTypeParameters
Description copied from interface:CtFormalTypeDeclarer
Returns the formal type parameters of this generic element.- Specified by:
getFormalCtTypeParameters
in interfaceCtFormalTypeDeclarer
-
setFormalCtTypeParameters
public <C extends CtFormalTypeDeclarer> C setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters)Description copied from interface:CtFormalTypeDeclarer
Sets the type parameters of this generic element.- Specified by:
setFormalCtTypeParameters
in interfaceCtFormalTypeDeclarer
-
addFormalCtTypeParameterAt
public <C extends CtFormalTypeDeclarer> C addFormalCtTypeParameterAt(int position, CtTypeParameter formalTypeParameter)Description copied from interface:CtFormalTypeDeclarer
Add a type parameter at a specific position.- Specified by:
addFormalCtTypeParameterAt
in interfaceCtFormalTypeDeclarer
- Parameters:
position
- Position to insert the type parameter atformalTypeParameter
- The type parameter to insert- Returns:
- The receiver
-
addFormalCtTypeParameter
public <C extends CtFormalTypeDeclarer> C addFormalCtTypeParameter(CtTypeParameter formalTypeParameter)Description copied from interface:CtFormalTypeDeclarer
Add a type parameter to this generic element.- Specified by:
addFormalCtTypeParameter
in interfaceCtFormalTypeDeclarer
-
removeFormalCtTypeParameter
Description copied from interface:CtFormalTypeDeclarer
Removes a type parameters from this generic element.- Specified by:
removeFormalCtTypeParameter
in interfaceCtFormalTypeDeclarer
-
getMethod
public <R> CtMethod<R> getMethod(CtTypeReference<R> returnType, String name, CtTypeReference<?>... parameterTypes)Description copied from interface:CtType
Gets a method from its return type, name, and parameter types. -
getMethod
Description copied from interface:CtType
Gets a method from its name and parameter types. -
hasSameParameters
protected boolean hasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) -
getMethods
Description copied from interface:CtType
Returns the methods that are directly declared by this class or interface. Derived fromCtType.getTypeMembers()
- Specified by:
getMethods
in interfaceCtType<T>
-
getMethodsAnnotatedWith
Description copied from interface:CtType
Returns the methods that are directly declared by this class or interface and annotated with one of the given annotations.- Specified by:
getMethodsAnnotatedWith
in interfaceCtType<T>
-
getMethodsByName
Description copied from interface:CtType
Returns the methods that are directly declared by this class or interface and that have the given name.- Specified by:
getMethodsByName
in interfaceCtType<T>
-
hasMethod
Description copied from interface:CtType
Searches in the type for the given method. Super classes and implemented interfaces are considered. The matching criterion is that the signatures are identical. -
setSimpleName
Description copied from interface:CtNamedElement
Sets the simple (unqualified) name of this element.- Specified by:
setSimpleName
in interfaceCtNamedElement
- Overrides:
setSimpleName
in classCtNamedElementImpl
-
getQualifiedName
Description copied from interface:CtTypeInformation
Returns the fully qualified name of this type declaration.- Specified by:
getQualifiedName
in interfaceCtTypeInformation
-
getSuperInterfaces
Description copied from interface:CtTypeInformation
Returns the interface types directly implemented by this class or extended by this interface.- Specified by:
getSuperInterfaces
in interfaceCtTypeInformation
-
setMethods
Description copied from interface:CtType
Sets the methods of this type.- Specified by:
setMethods
in interfaceCtType<T>
-
setSuperclass
Description copied from interface:CtType
Sets the superclass type.- Specified by:
setSuperclass
in interfaceCtType<T>
-
setSuperInterfaces
Description copied from interface:CtType
Sets the super interfaces of this type.- Specified by:
setSuperInterfaces
in interfaceCtType<T>
-
getDeclaredExecutables
Description copied from interface:CtTypeInformation
Gets the executables declared by this type if applicable.- Specified by:
getDeclaredExecutables
in interfaceCtTypeInformation
-
getAllExecutables
Description copied from interface:CtTypeInformation
Gets the executables declared by this type and by all its supertypes (static/instance methods, constructors, anonymous static blocks) if applicable. This method returns:- static, instance and default methods
- constructors
- Specified by:
getAllExecutables
in interfaceCtTypeInformation
-
getAllMethods
Description copied from interface:CtType
Return all the methods that can be called on an instance of this type. It recursively collects all methods (both concrete and abstract) from all super-classes and all super-interfaces. It deduplicates methods with the same signature, which are defined several times somewhere in the type hierarchy. Warning: this method can be really slow due to signature deduplication. It includes all methods: the methods of types whose source code is in the Spoon model, the methods of types from the JDK and from libraries present in the classpath, the methods of java.lang.Object (for all CtClass objects). However, in noclasspath mode, it does not include methods from unknown types. If methods are overridden somewhere in the type hierarchy, it returns only top methods (ie method definitions).- Specified by:
getAllMethods
in interfaceCtType<T>
-
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
- Returns:
- a reference to the erased type
- See Also:
- Type Erasure
-
isShadow
public boolean isShadow()Description copied from interface:CtShadowable
When an element isn't present in the factory (created in another factory), this element is considered as "shadow". e.g., a shadow element can be a CtType of java.lang.Class built when we callCtTypeReference.getTypeDeclaration()
on a reference of java.lang.Class.- Specified by:
isShadow
in interfaceCtShadowable
- Returns:
- true if the element is a shadow element, otherwise false.
-
setShadow
Description copied from interface:CtShadowable
Marks an element as shadow. To know what is a shadow element, see the javadoc ofCtShadowable.isShadow()
.- Specified by:
setShadow
in interfaceCtShadowable
-
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 interfaceCtNamedElement
- Specified by:
clone
in interfaceCtType<T>
- Overrides:
clone
in classCtNamedElementImpl
-
isPublic
public boolean isPublic()Description copied from interface:CtModifiable
Returns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isPublic
in interfaceCtModifiable
-
isPrivate
public boolean isPrivate()Description copied from interface:CtModifiable
Returns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isPrivate
in interfaceCtModifiable
-
isProtected
public boolean isProtected()Description copied from interface:CtModifiable
Returns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isProtected
in interfaceCtModifiable
-
isFinal
public boolean isFinal()Description copied from interface:CtModifiable
Returns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isFinal
in interfaceCtModifiable
-
isStatic
public boolean isStatic()Description copied from interface:CtModifiable
Returns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isStatic
in interfaceCtModifiable
-
isAbstract
public boolean isAbstract()Description copied from interface:CtModifiable
Returns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isAbstract
in interfaceCtModifiable
-
isTransient
public boolean isTransient()Description copied from interface:CtModifiable
Returns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isTransient
in interfaceCtModifiable
-
isSynchronized
public boolean isSynchronized()Description copied from interface:CtModifiable
Returns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isSynchronized
in interfaceCtModifiable
-
isNative
public boolean isNative()Description copied from interface:CtModifiable
Returns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isNative
in interfaceCtModifiable
-
isStrictfp
public boolean isStrictfp()Description copied from interface:CtModifiable
Returns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isStrictfp
in interfaceCtModifiable
-
isVolatile
public boolean isVolatile()Description copied from interface:CtModifiable
Returns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind)
)- Specified by:
isVolatile
in interfaceCtModifiable
-
copyType
Description copied from interface:CtType
Copy the type, where copy means cloning + porting all the references in the clone from the old type to the new type. The copied type is added to the same package (and this to the factory as well). A new unique method name is given for each copy, and this method can be called several times. -
isArray
public boolean isArray()Description copied from interface:CtTypeInformation
Returns true if this type represents an array likeObject[]
orint[]
.- Specified by:
isArray
in interfaceCtTypeInformation
- Returns:
- true if this type represents an array like
Object[]
orint[]
-
toStringWithImports
Description copied from interface:CtType
Gets the entire class code with package and imports.- Specified by:
toStringWithImports
in interfaceCtType<T>
-