public interface CtType<T> extends CtNamedElement, CtTypeInformation, CtTypeMember, CtFormalTypeDeclarer, CtShadowable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INNERTTYPE_SEPARATOR
The string separator in a Java innertype qualified name.
|
static java.lang.String |
NAME_UNKNOWN
Used in no classpath when we don't have any information to build the name of the type.
|
Modifier and Type | Method and Description |
---|---|
<F,C extends CtType<T>> |
addField(CtField<F> field)
add a field at the end of the field list.
|
<F,C extends CtType<T>> |
addField(int index,
CtField<F> field)
add a field at a given position.
|
<F,C extends CtType<T>> |
addFieldAtTop(CtField<F> field)
Adds a field at the top of the type (before static block).
|
<M,C extends CtType<T>> |
addMethod(CtMethod<M> method)
Adds a method to this type.
|
<N,C extends CtType<T>> |
addNestedType(CtType<N> nestedType)
Add a nested type.
|
<S,C extends CtType<T>> |
addSuperInterface(CtTypeReference<S> interfac) |
<C extends CtType<T>> |
addTypeMember(CtTypeMember member)
Adds a type member at the end of all type member of the type.
|
<C extends CtType<T>> |
addTypeMemberAt(int position,
CtTypeMember member)
Adds a type member at a given position.
|
CtType<T> |
clone()
Clone the element which calls this method in a new object.
|
void |
compileAndReplaceSnippets()
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.
|
java.lang.Class<T> |
getActualClass()
Deprecated.
(since Spoon 7.0.0) this will be removed from the public API
|
java.util.Set<CtMethod<?>> |
getAllMethods()
Return all the methods that can be called on an instance of this type.
|
CtField<?> |
getField(java.lang.String name)
Gets a field from its name.
|
java.util.List<CtField<?>> |
getFields()
Returns the fields that are directly declared by this class or interface.
|
<R> CtMethod<R> |
getMethod(CtTypeReference<R> returnType,
java.lang.String name,
CtTypeReference<?>... parameterTypes)
Gets a method from its return type, name, and parameter types.
|
<R> CtMethod<R> |
getMethod(java.lang.String name,
CtTypeReference<?>... parameterTypes)
Gets a method from its name and parameter types.
|
java.util.Set<CtMethod<?>> |
getMethods()
Returns the methods that are directly declared by this class or
interface.
|
java.util.Set<CtMethod<?>> |
getMethodsAnnotatedWith(CtTypeReference<?>... annotationTypes)
Returns the methods that are directly declared by this class or
interface and annotated with one of the given annotations.
|
java.util.List<CtMethod<?>> |
getMethodsByName(java.lang.String name)
Returns the methods that are directly declared by this class or
interface and that have the given name.
|
<N extends CtType<?>> |
getNestedType(java.lang.String name)
Gets a nested type from its name.
|
java.util.Set<CtType<?>> |
getNestedTypes()
Returns the declarations of the nested classes and interfaces that are
directly declared by this class or interface.
|
CtPackage |
getPackage()
Gets the package where this type is declared.
|
CtTypeReference<T> |
getReference()
Returns the corresponding type reference.
|
java.lang.String |
getSimpleName()
Returns the simple (unqualified) name of this element.
|
java.util.List<CtTypeMember> |
getTypeMembers()
Gets all type members of the type like fields, methods, anonymous block, etc.
|
java.util.Set<CtTypeReference<?>> |
getUsedTypes(boolean includeSamePackage)
Returns the types used by this type.
|
boolean |
hasMethod(CtMethod<?> method)
Searches in the type for the given method.
|
boolean |
isTopLevel()
Returns true if this type is top-level (declared as the main type in a
file).
|
<F> boolean |
removeField(CtField<F> field)
remove a Field
|
<M> boolean |
removeMethod(CtMethod<M> method)
Removes a method from this type.
|
<N> boolean |
removeNestedType(CtType<N> nestedType)
Remove a nested type.
|
<S> boolean |
removeSuperInterface(CtTypeReference<S> interfac) |
boolean |
removeTypeMember(CtTypeMember member)
Removes the type member.
|
<C extends CtType<T>> |
setFields(java.util.List<CtField<?>> fields)
Sets all fields in the type.
|
<C extends CtType<T>> |
setMethods(java.util.Set<CtMethod<?>> methods)
Sets the methods of this type.
|
<C extends CtType<T>> |
setNestedTypes(java.util.Set<CtType<?>> nestedTypes)
Sets all nested types.
|
<C extends CtType<T>> |
setSuperclass(CtTypeReference<?> superClass)
Sets the superclass type.
|
<C extends CtType<T>> |
setSuperInterfaces(java.util.Set<CtTypeReference<?>> interfaces)
Sets the super interfaces of this type.
|
<C extends CtType<T>> |
setTypeMembers(java.util.List<CtTypeMember> members)
Removes all types members with these new members.
|
java.lang.String |
toStringWithImports()
Gets the entire class code with package and imports.
|
getAllExecutables, getAllFields, getDeclaredExecutables, getDeclaredField, getDeclaredFields, getDeclaredOrInheritedField, getModifiers, getQualifiedName, getSuperclass, getSuperInterfaces, getTypeErasure, isAnnotationType, isAnonymous, isArray, isClass, isEnum, isGenerics, isInterface, isLocalType, isParameterized, isPrimitive, isSubtypeOf
addFormalCtTypeParameter, getFormalCtTypeParameters, removeFormalCtTypeParameter, setFormalCtTypeParameters
getDeclaringType, getTopLevelType
addModifier, getExtendedModifiers, getModifiers, getVisibility, hasModifier, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile, removeModifier, setExtendedModifiers, setModifiers, setVisibility
setSimpleName
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
getFactory, setFactory
accept
filterChildren, map, map
isShadow, setShadow
static final java.lang.String INNERTTYPE_SEPARATOR
static final java.lang.String NAME_UNKNOWN
java.lang.String getSimpleName()
getSimpleName
in interface CtNamedElement
java.util.Set<CtTypeReference<?>> getUsedTypes(boolean includeSamePackage)
includeSamePackage
- set to true if the method should return also the types located
in the same package as the current typejava.lang.Class<T> getActualClass()
CtTypeReference.getActualClass()
.CtField<?> getField(java.lang.String name)
java.util.List<CtField<?>> getFields()
getTypeMembers()
<N extends CtType<?>> N getNestedType(java.lang.String name)
java.util.Set<CtType<?>> getNestedTypes()
CtPackage getPackage()
java.lang.String toStringWithImports()
CtTypeReference<T> getReference()
getReference
in interface CtNamedElement
boolean isTopLevel()
<F,C extends CtType<T>> C addFieldAtTop(CtField<F> field)
field
- <F,C extends CtType<T>> C addField(CtField<F> field)
field
- <F,C extends CtType<T>> C addField(int index, CtField<F> field)
field
- <C extends CtType<T>> C setFields(java.util.List<CtField<?>> fields)
<F> boolean removeField(CtField<F> field)
field
- <N,C extends CtType<T>> C addNestedType(CtType<N> nestedType)
nestedType
- <N> boolean removeNestedType(CtType<N> nestedType)
nestedType
- <C extends CtType<T>> C setNestedTypes(java.util.Set<CtType<?>> nestedTypes)
void compileAndReplaceSnippets()
java.util.Set<CtMethod<?>> getAllMethods()
<R> CtMethod<R> getMethod(CtTypeReference<R> returnType, java.lang.String name, CtTypeReference<?>... parameterTypes)
<R> CtMethod<R> getMethod(java.lang.String name, CtTypeReference<?>... parameterTypes)
java.util.Set<CtMethod<?>> getMethods()
getTypeMembers()
java.util.Set<CtMethod<?>> getMethodsAnnotatedWith(CtTypeReference<?>... annotationTypes)
java.util.List<CtMethod<?>> getMethodsByName(java.lang.String name)
boolean hasMethod(CtMethod<?> method)
method
- The method to search for in the class.<C extends CtType<T>> C setMethods(java.util.Set<CtMethod<?>> methods)
<M> boolean removeMethod(CtMethod<M> method)
<C extends CtType<T>> C setSuperclass(CtTypeReference<?> superClass)
<C extends CtType<T>> C setSuperInterfaces(java.util.Set<CtTypeReference<?>> interfaces)
<S,C extends CtType<T>> C addSuperInterface(CtTypeReference<S> interfac)
interfac
- <S> boolean removeSuperInterface(CtTypeReference<S> interfac)
interfac
- java.util.List<CtTypeMember> getTypeMembers()
<C extends CtType<T>> C addTypeMember(CtTypeMember member)
<C extends CtType<T>> C addTypeMemberAt(int position, CtTypeMember member)
boolean removeTypeMember(CtTypeMember member)
<C extends CtType<T>> C setTypeMembers(java.util.List<CtTypeMember> members)
CtType<T> clone()
CtElement
Refactoring.copyType(CtType)
and Refactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.clone
in interface CtElement
clone
in interface CtNamedElement
CtType<?> copyType()
Copyright © 2007–2021 Inria. All rights reserved.