Class CtExecutableImpl<R>
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.declaration.CtNamedElementImpl
spoon.support.reflect.declaration.CtExecutableImpl<R>
- All Implemented Interfaces:
Serializable,Cloneable,FactoryAccessor,CtBodyHolder,SourcePositionHolder,CtElement,CtExecutable<R>,CtNamedElement,CtTypedElement<R>,CtQueryable,CtVisitable
- Direct Known Subclasses:
CtAnonymousExecutableImpl,CtConstructorImpl,CtMethodImpl
The implementation for
CtExecutable.- Author:
- Renaud Pawlak
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parentFields inherited from interface spoon.reflect.declaration.CtExecutable
EXECUTABLE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends CtExecutable<R>>
TaddParameter(CtParameter<?> parameter)Add a parameter for this executable<T extends CtExecutable<R>>
TaddParameterAt(int position, CtParameter<?> parameter)Add a parameter at a specific position in the executable.<T extends CtExecutable<R>>
TaddThrownType(CtTypeReference<? extends Throwable> throwType)add a thrown type.clone()Clone the element which calls this method in a new object.getBody()Gets the body expression.CtType<?>List<CtParameter<?>>Gets the parameters list.Returns the corresponding reference.Gets the signature of this exectuable.Set<CtTypeReference<? extends Throwable>>Returns the exceptions and other throwables listed in this method or constructor's throws clause.<T> CtType<T>booleanremoveParameter(CtParameter<?> parameter)Remove a parameter for this executablebooleanremoveThrownType(CtTypeReference<? extends Throwable> throwType)remove a thrown type.<T extends CtBodyHolder>
TsetBody(CtStatement statement)Sets the body of this element.<T extends CtExecutable<R>>
TsetParameters(List<CtParameter<?>> parameters)Sets the parameters.<T extends CtExecutable<R>>
TsetThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes)Sets the thrown types.Methods inherited from class spoon.support.reflect.declaration.CtNamedElementImpl
getSimpleName, setSimpleNameMethods 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.declaration.CtNamedElement
getSimpleName, setSimpleNameMethods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, mapMethods inherited from interface spoon.reflect.declaration.CtTypedElement
getType, setTypeMethods inherited from interface spoon.reflect.visitor.CtVisitable
acceptMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtExecutableImpl
public CtExecutableImpl()
-
-
Method Details
-
getDeclaringType
-
getTopLevelType
-
getBody
Description copied from interface:CtExecutableGets the body expression.- Specified by:
getBodyin interfaceCtBodyHolder- Specified by:
getBodyin interfaceCtExecutable<R>
-
setBody
Description copied from interface:CtBodyHolderSets the body of this element. If body is not a block, it is wrapped in a CtBlock which is semantically equivalent and eases transformation afterwards if required.- Specified by:
setBodyin interfaceCtBodyHolder
-
getParameters
Description copied from interface:CtExecutableGets the parameters list.- Specified by:
getParametersin interfaceCtExecutable<R>
-
setParameters
Description copied from interface:CtExecutableSets the parameters.- Specified by:
setParametersin interfaceCtExecutable<R>
-
addParameter
Description copied from interface:CtExecutableAdd a parameter for this executable- Specified by:
addParameterin interfaceCtExecutable<R>- Returns:
- true if this element changed as a result of the call
-
addParameterAt
Description copied from interface:CtExecutableAdd a parameter at a specific position in the executable.- Specified by:
addParameterAtin interfaceCtExecutable<R>- Parameters:
position- index where the `parameter` needs to be insertedparameter- parameter to be inserted- Returns:
- an object or sub-type of
CtExecutable
-
removeParameter
Description copied from interface:CtExecutableRemove a parameter for this executable- Specified by:
removeParameterin interfaceCtExecutable<R>- Returns:
- true if this element changed as a result of the call
-
getThrownTypes
Description copied from interface:CtExecutableReturns the exceptions and other throwables listed in this method or constructor's throws clause.- Specified by:
getThrownTypesin interfaceCtExecutable<R>
-
setThrownTypes
public <T extends CtExecutable<R>> T setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes)Description copied from interface:CtExecutableSets the thrown types.- Specified by:
setThrownTypesin interfaceCtExecutable<R>
-
addThrownType
Description copied from interface:CtExecutableadd a thrown type.- Specified by:
addThrownTypein interfaceCtExecutable<R>- Returns:
- true if this element changed as a result of the call
-
removeThrownType
Description copied from interface:CtExecutableremove a thrown type.- Specified by:
removeThrownTypein interfaceCtExecutable<R>- Returns:
- true if this element changed as a result of the call
-
getSignature
Description copied from interface:CtExecutableGets the signature of this exectuable. The signature is composed of the method name and the parameter types, all fully-qualified, eg "foo(java.lang.String)". The core contract is that in a type, there cannot be two methods with the same signature.Note that the concept of method signature in Java is not well defined (see chapter "8.4.2 Method Signature" of the Java specification, which defines what relations between signatures but not what a signature is exactly).
Note also that the signature of a method reference is the same as the signature of the corresponding method if and only if the method parameters does not involve generics in their types. Otherwise, one has eg m(String) (reference) and m(T) (declaration)
Reference: "In the Java programming language, a method signature is the method name and the number and type of its parameters. Return types and thrown exceptions are not considered to be a part of the method signature."
see Stackoverflow
see Wikipedia- Specified by:
getSignaturein interfaceCtExecutable<R>
-
getReference
Description copied from interface:CtNamedElementReturns the corresponding reference.- Specified by:
getReferencein interfaceCtExecutable<R>- Specified by:
getReferencein interfaceCtNamedElement- Overrides:
getReferencein classCtNamedElementImpl
-
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 interfaceCtExecutable<R>- Specified by:
clonein interfaceCtNamedElement- Overrides:
clonein classCtNamedElementImpl
-