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:
-
Field Summary
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parentFields inherited from interface spoon.reflect.declaration.CtType
INNERTTYPE_SEPARATOR, NAME_UNKNOWN -
Constructor Summary
Constructors -
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.voidReplace 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.booleanSearches in the type for the given method.booleanhasModifier(ModifierKind modifier) Tells if this element contains the given modifier.protected booleanhasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) booleanReturns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if this type is an annotation type.booleanReturntrueif the referenced type is an anonymous typebooleanisArray()Returns true if this type represents an array likeObject[]orint[].booleanisClass()Returns true if this type is a class.booleanisEnum()Returns true if this type is an enum.booleanisFinal()Returns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it is not a concrete, resolvable class, it if refers to a type parameter directly or indirectly.booleanReturns true if this type is an interface.booleanReturnstrueif the referenced type is declared in an executable.booleanisNative()Returns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it has any type parameter (generic or not).booleanChecks if the referenced type is a primitive type.booleanReturns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind))booleanisPublic()Returns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind))booleanisShadow()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.booleanisStatic()Returns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if this type is top-level (declared as the main type in a file).booleanReturns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind))booleanReturns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind))<F> booleanremoveField(CtField<F> field) remove a FieldbooleanremoveFormalCtTypeParameter(CtTypeParameter formalTypeParameter) Removes a type parameters from this generic element.<M> booleanremoveMethod(CtMethod<M> method) Removes a method from this type.<C extends CtModifiable>
CremoveModifier(ModifierKind modifier) remove a modifier<N> booleanremoveNestedType(CtType<N> nestedType) Remove a nested type.<S> booleanremoveSuperInterface(CtTypeReference<S> interfac) booleanremoveTypeMember(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
getSimpleNameMethods 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, 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, setComments, 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.declaration.CtType
getSimpleNameMethods inherited from interface spoon.reflect.declaration.CtTypeInformation
isSubtypeOfMethods inherited from interface spoon.reflect.visitor.CtVisitable
acceptMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtTypeImpl
protected CtTypeImpl()
-
-
Method Details
-
getTypeMembers
Description copied from interface:CtTypeGets all type members of the type like fields, methods, anonymous block, etc.- Specified by:
getTypeMembersin 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:
addTypeMemberin interfaceCtType<T>
-
addTypeMemberAt
Description copied from interface:CtTypeAdds a type member at a given position. Think to use this method if the order is important for you.- Specified by:
addTypeMemberAtin interfaceCtType<T>
-
removeTypeMember
Description copied from interface:CtTypeRemoves the type member.- Specified by:
removeTypeMemberin interfaceCtType<T>
-
setTypeMembers
Description copied from interface:CtTypeRemoves all types members with these new members.- Specified by:
setTypeMembersin interfaceCtType<T>
-
addFieldAtTop
Description copied from interface:CtTypeAdds 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:
addFieldAtTopin interfaceCtType<T>- Returns:
- true if the field is added.
-
addField
Description copied from interface:CtTypeadd a field at the end of the field list. -
addField
Description copied from interface:CtTypeadd a field at a given position. -
setFields
Description copied from interface:CtTypeSets all fields in the type. -
removeField
Description copied from interface:CtTyperemove a Field- Specified by:
removeFieldin interfaceCtType<T>- Returns:
- true if this element changed as a result of the call
-
getField
Description copied from interface:CtTypeGets a field from its name. -
getDeclaredField
Description copied from interface:CtTypeInformationGets a field from its name.- Specified by:
getDeclaredFieldin interfaceCtTypeInformation- Returns:
- a reference to the field with the name or
nullif it does not exist
-
getDeclaredOrInheritedField
Description copied from interface:CtTypeInformationGets a field from this type or any super type or any implemented interface by field name.- Specified by:
getDeclaredOrInheritedFieldin interfaceCtTypeInformation- Returns:
- a reference to the field with the name or
nullif it does not exist
-
getFields
Description copied from interface:CtTypeReturns the fields that are directly declared by this class or interface. Includes enum constants. Derived fromCtType.getTypeMembers() -
addNestedType
Description copied from interface:CtTypeAdd a nested type.- Specified by:
addNestedTypein interfaceCtType<T>- Returns:
- true if this element changed as a result of the call
-
removeNestedType
Description copied from interface:CtTypeRemove a nested type.- Specified by:
removeNestedTypein interfaceCtType<T>- Returns:
- true if this element changed as a result of the call
-
setNestedTypes
Description copied from interface:CtTypeSets all nested types.- Specified by:
setNestedTypesin interfaceCtType<T>
-
getUsedTypes
Description copied from interface:CtTypeReturns the types used by this type.- Specified by:
getUsedTypesin 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:CtTypeThis is a low-level feature, it should never been used by non advanced users. See full documentation atCtTypeReference.getActualClass().- Specified by:
getActualClassin interfaceCtType<T>
-
getDeclaringType
Description copied from interface:CtTypeMemberGets the type that declares this class member.- Specified by:
getDeclaringTypein interfaceCtTypeMember- Returns:
- declaring class
-
getTopLevelType
Description copied from interface:CtTypeMemberReturns 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:
getTopLevelTypein interfaceCtTypeMember
-
getNestedType
Description copied from interface:CtTypeGets a nested type from its name.- Specified by:
getNestedTypein interfaceCtType<T>
-
getNestedTypes
Description copied from interface:CtTypeReturns the declarations of the nested classes and interfaces that are directly declared by this class or interface.- Specified by:
getNestedTypesin interfaceCtType<T>
-
getPackage
Description copied from interface:CtTypeGets the package where this type is declared.- Specified by:
getPackagein interfaceCtType<T>
-
getReference
Description copied from interface:CtNamedElementReturns the corresponding reference.- Specified by:
getReferencein interfaceCtNamedElement- Specified by:
getReferencein interfaceCtType<T>- Overrides:
getReferencein classCtNamedElementImpl- Returns:
- the corresponding reference
-
isTopLevel
public boolean isTopLevel()Description copied from interface:CtTypeReturns true if this type is top-level (declared as the main type in a file).- Specified by:
isTopLevelin interfaceCtType<T>
-
compileAndReplaceSnippets
public void compileAndReplaceSnippets()Description copied from interface:CtTypeReplace all the code snippets that are found in this type by the corresponding Spoon AST.- Specified by:
compileAndReplaceSnippetsin interfaceCtType<T>- See Also:
-
getModifiers
Description copied from interface:CtTypeInformationGets modifiers of this type.- Specified by:
getModifiersin interfaceCtModifiable- Specified by:
getModifiersin interfaceCtTypeInformation- Returns:
- the modifiers of this declaration in undefined order; an empty set if there are none
-
hasModifier
Description copied from interface:CtModifiableTells if this element contains the given modifier.- Specified by:
hasModifierin interfaceCtModifiable- Parameters:
modifier- to search- Returns:
trueif this element contain the modifier
-
setModifiers
Description copied from interface:CtModifiableSets the modifiers.- Specified by:
setModifiersin interfaceCtModifiable
-
addModifier
Description copied from interface:CtModifiableadd a modifier- Specified by:
addModifierin interfaceCtModifiable
-
removeModifier
Description copied from interface:CtModifiableremove a modifier- Specified by:
removeModifierin interfaceCtModifiable
-
setVisibility
Description copied from interface:CtModifiableSets the visibility of this modifiable element (replaces old visibility).- Specified by:
setVisibilityin interfaceCtModifiable
-
getVisibility
Description copied from interface:CtModifiableGets the visibility of this modifiable element.- Specified by:
getVisibilityin interfaceCtModifiable
-
getExtendedModifiers
- Specified by:
getExtendedModifiersin interfaceCtModifiable- Returns:
- the set of extended modifiers (those incl. implicit).
-
setExtendedModifiers
- Specified by:
setExtendedModifiersin interfaceCtModifiable
-
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- Returns:
trueif the referenced type is a primitive type
-
isAnonymous
public boolean isAnonymous()Description copied from interface:CtTypeInformationReturntrueif the referenced type is an anonymous type- Specified by:
isAnonymousin interfaceCtTypeInformation
-
isLocalType
public boolean isLocalType()Description copied from interface:CtTypeInformationReturnstrueif the referenced type is declared in an executable. e.g. a type declared in a method or a lambda. This corresponds toisLocalClassofjava.lang.Class.// Type declared in a method. public void make() { class Cook { } } // Type declared in a lambda. s -> { class Cook { } }- Specified by:
isLocalTypein interfaceCtTypeInformation
-
getSuperclass
Description copied from interface:CtTypeInformationReturns a reference to the type directly extended by this type.To get the
CtTypeof the super class, useCtTypeReference.getDeclaration()orCtTypeReference.getTypeDeclaration()on theCtTypeReferencereturned by this method.- Specified by:
getSuperclassin interfaceCtTypeInformation- Returns:
- the type explicitly extended by this type, or
nullif there is none or if the super type is not in the classpath (in noclasspath mode). If a class does not explicitly extend another classnullis 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:CtTypeInformationReturns true if this type is a class. Returns false for others (enum, interface, generics, annotation).- Specified by:
isClassin interfaceCtTypeInformation
-
isInterface
public boolean isInterface()Description copied from interface:CtTypeInformationReturns true if this type is an interface.- Specified by:
isInterfacein interfaceCtTypeInformation
-
isAnnotationType
public boolean isAnnotationType()Description copied from interface:CtTypeInformationReturns true if this type is an annotation type.- Specified by:
isAnnotationTypein interfaceCtTypeInformation
-
isEnum
public boolean isEnum()Description copied from interface:CtTypeInformationReturns true if this type is an enum.- Specified by:
isEnumin interfaceCtTypeInformation
-
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
-
isParameterized
public boolean isParameterized()Description copied from interface:CtTypeInformationReturns true if it has any type parameter (generic or not).- Specified by:
isParameterizedin interfaceCtTypeInformation
-
getAllFields
Description copied from interface:CtTypeInformationGets the fields declared by this type and by all its supertypes if applicable.- Specified by:
getAllFieldsin interfaceCtTypeInformation
-
getDeclaredFields
Description copied from interface:CtTypeInformationGets the fields declared by this type.- Specified by:
getDeclaredFieldsin interfaceCtTypeInformation
-
addMethod
Description copied from interface:CtTypeAdds a method to this type. -
removeMethod
Description copied from interface:CtTypeRemoves a method from this type.- Specified by:
removeMethodin interfaceCtType<T>
-
addSuperInterface
- Specified by:
addSuperInterfacein interfaceCtType<T>- Returns:
- true if this element changed as a result of the call
-
removeSuperInterface
- Specified by:
removeSuperInterfacein interfaceCtType<T>- Returns:
- true if this element changed as a result of the call
-
getFormalCtTypeParameters
Description copied from interface:CtFormalTypeDeclarerReturns the formal type parameters of this generic element.- Specified by:
getFormalCtTypeParametersin interfaceCtFormalTypeDeclarer
-
setFormalCtTypeParameters
public <C extends CtFormalTypeDeclarer> C setFormalCtTypeParameters(List<CtTypeParameter> formalTypeParameters) Description copied from interface:CtFormalTypeDeclarerSets the type parameters of this generic element.- Specified by:
setFormalCtTypeParametersin interfaceCtFormalTypeDeclarer
-
addFormalCtTypeParameterAt
public <C extends CtFormalTypeDeclarer> C addFormalCtTypeParameterAt(int position, CtTypeParameter formalTypeParameter) Description copied from interface:CtFormalTypeDeclarerAdd a type parameter at a specific position.- Specified by:
addFormalCtTypeParameterAtin 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:CtFormalTypeDeclarerAdd a type parameter to this generic element.- Specified by:
addFormalCtTypeParameterin interfaceCtFormalTypeDeclarer
-
removeFormalCtTypeParameter
Description copied from interface:CtFormalTypeDeclarerRemoves a type parameters from this generic element.- Specified by:
removeFormalCtTypeParameterin interfaceCtFormalTypeDeclarer
-
getMethod
public <R> CtMethod<R> getMethod(CtTypeReference<R> returnType, String name, CtTypeReference<?>... parameterTypes) Description copied from interface:CtTypeGets a method from its return type, name, and parameter types. -
getMethod
Description copied from interface:CtTypeGets a method from its name and parameter types. -
hasSameParameters
protected boolean hasSameParameters(CtExecutable<?> candidate, CtTypeReference<?>... parameterTypes) -
getMethods
Description copied from interface:CtTypeReturns the methods that are directly declared by this class or interface. Derived fromCtType.getTypeMembers()- Specified by:
getMethodsin interfaceCtType<T>
-
getMethodsAnnotatedWith
Description copied from interface:CtTypeReturns the methods that are directly declared by this class or interface and annotated with one of the given annotations.- Specified by:
getMethodsAnnotatedWithin interfaceCtType<T>
-
getMethodsByName
Description copied from interface:CtTypeReturns the methods that are directly declared by this class or interface and that have the given name.- Specified by:
getMethodsByNamein interfaceCtType<T>
-
hasMethod
Description copied from interface:CtTypeSearches 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:CtNamedElementSets the simple (unqualified) name of this element.- Specified by:
setSimpleNamein interfaceCtNamedElement- Overrides:
setSimpleNamein classCtNamedElementImpl
-
getQualifiedName
Description copied from interface:CtTypeInformationReturns the fully qualified name of this type declaration.- Specified by:
getQualifiedNamein interfaceCtTypeInformation
-
getSuperInterfaces
Description copied from interface:CtTypeInformationReturns the interface types directly implemented by this class or extended by this interface.- Specified by:
getSuperInterfacesin interfaceCtTypeInformation
-
setMethods
Description copied from interface:CtTypeSets the methods of this type.- Specified by:
setMethodsin interfaceCtType<T>
-
setSuperclass
Description copied from interface:CtTypeSets the superclass type.- Specified by:
setSuperclassin interfaceCtType<T>
-
setSuperInterfaces
Description copied from interface:CtTypeSets the super interfaces of this type.- Specified by:
setSuperInterfacesin interfaceCtType<T>
-
getDeclaredExecutables
Description copied from interface:CtTypeInformationGets the executables declared by this type if applicable.- Specified by:
getDeclaredExecutablesin interfaceCtTypeInformation
-
getAllExecutables
Description copied from interface:CtTypeInformationGets 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:
getAllExecutablesin interfaceCtTypeInformation
-
getAllMethods
Description copied from interface:CtTypeReturn 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:
getAllMethodsin interfaceCtType<T>
-
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- Returns:
- a reference to the erased type
- See Also:
-
isShadow
public boolean isShadow()Description copied from interface:CtShadowableWhen 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:
isShadowin interfaceCtShadowable- Returns:
- true if the element is a shadow element, otherwise false.
-
setShadow
Description copied from interface:CtShadowableMarks an element as shadow. To know what is a shadow element, see the javadoc ofCtShadowable.isShadow().- Specified by:
setShadowin interfaceCtShadowable
-
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 interfaceCtNamedElement- Specified by:
clonein interfaceCtType<T>- Overrides:
clonein classCtNamedElementImpl- Returns:
- a clone of this element. All children are cloned, but the parent of the returned clone is set to null.
-
isPublic
public boolean isPublic()Description copied from interface:CtModifiableReturns true if it contains a public modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isPublicin interfaceCtModifiable
-
isPrivate
public boolean isPrivate()Description copied from interface:CtModifiableReturns true if it contains a private modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isPrivatein interfaceCtModifiable
-
isProtected
public boolean isProtected()Description copied from interface:CtModifiableReturns true if it contains a protected modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isProtectedin interfaceCtModifiable
-
isFinal
public boolean isFinal()Description copied from interface:CtModifiableReturns true if it contains a final modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isFinalin interfaceCtModifiable
-
isStatic
public boolean isStatic()Description copied from interface:CtModifiableReturns true if it contains a static modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isStaticin interfaceCtModifiable
-
isAbstract
public boolean isAbstract()Description copied from interface:CtModifiableReturns true if it contains an abstract modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isAbstractin interfaceCtModifiable
-
isTransient
public boolean isTransient()Description copied from interface:CtModifiableReturns true if it contains a transient modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isTransientin interfaceCtModifiable
-
isSynchronized
public boolean isSynchronized()Description copied from interface:CtModifiableReturns true if it contains a synchronized modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isSynchronizedin interfaceCtModifiable
-
isNative
public boolean isNative()Description copied from interface:CtModifiableReturns true if it contains a native modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isNativein interfaceCtModifiable
-
isStrictfp
public boolean isStrictfp()Description copied from interface:CtModifiableReturns true if it contains a strictfp modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isStrictfpin interfaceCtModifiable
-
isVolatile
public boolean isVolatile()Description copied from interface:CtModifiableReturns true if it contains a volatile modifier (seeCtModifiable.hasModifier(ModifierKind))- Specified by:
isVolatilein interfaceCtModifiable
-
copyType
Description copied from interface:CtTypeCopy 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:CtTypeInformationReturns true if this type represents an array likeObject[]orint[].- Specified by:
isArrayin interfaceCtTypeInformation- Returns:
- true if this type represents an array like
Object[]orint[]
-
toStringWithImports
Description copied from interface:CtTypeGets the entire class code with package and imports.- Specified by:
toStringWithImportsin interfaceCtType<T>
-