Package spoon.support.reflect.code
Class CtLambdaImpl<T>
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.code.CtCodeElementImpl
spoon.support.reflect.code.CtExpressionImpl<T>
spoon.support.reflect.code.CtLambdaImpl<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,FactoryAccessor
,CtBodyHolder
,CtCodeElement
,CtExpression<T>
,CtLambda<T>
,SourcePositionHolder
,CtElement
,CtExecutable<T>
,CtNamedElement
,CtTypedElement<T>
,CtQueryable
,CtVisitable
,TemplateParameter<T>
- 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.CtExecutable
EXECUTABLE_SEPARATOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts a visitor<C extends CtExecutable<T>>
CaddParameter(CtParameter<?> parameter)
Add a parameter for this executable<C extends CtExecutable<T>>
CaddParameterAt(int position, CtParameter<?> parameter)
Add a parameter at a specific position in the executable.<C extends CtExecutable<T>>
CaddThrownType(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.Gets the expression in the body.<R> CtMethod<R>
List<CtParameter<?>>
Gets the parameters list.Returns the corresponding reference.Gets the signature of this exectuable.Returns the simple (unqualified) name of this element.Set<CtTypeReference<? extends Throwable>>
Returns the exceptions and other throwables listed in this method or constructor's throws clause.boolean
removeParameter(CtParameter<?> parameter)
Remove a parameter for this executableboolean
removeThrownType(CtTypeReference<? extends Throwable> throwType)
remove a thrown type.<C extends CtBodyHolder>
CsetBody(CtStatement statement)
Sets the body of this element.setExpression(CtExpression<T> expression)
Sets the expression in the body of the lambda.<C extends CtExecutable<T>>
CsetParameters(List<CtParameter<?>> params)
Sets the parameters.<C extends CtNamedElement>
CsetSimpleName(String simpleName)
Sets the simple (unqualified) name of this element.<C extends CtExecutable<T>>
CsetThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes)
Sets the thrown types.<C extends CtTypedElement>
CsetType(CtTypeReference type)
Sets this element's type.Methods inherited from class spoon.support.reflect.code.CtExpressionImpl
addTypeCast, getType, getTypeCasts, S, setTypeCasts
Methods inherited from class spoon.support.reflect.code.CtCodeElementImpl
partiallyEvaluate
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.code.CtCodeElement
partiallyEvaluate
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.code.CtExpression
addTypeCast, getTypeCasts, setTypeCasts
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.declaration.CtTypedElement
getType
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
Methods inherited from interface spoon.template.TemplateParameter
S
-
Constructor Details
-
CtLambdaImpl
public CtLambdaImpl()
-
-
Method Details
-
accept
Description copied from interface:CtVisitable
Accepts a visitor- Specified by:
accept
in interfaceCtVisitable
-
getSimpleName
Description copied from interface:CtNamedElement
Returns the simple (unqualified) name of this element.- Specified by:
getSimpleName
in interfaceCtNamedElement
-
setSimpleName
Description copied from interface:CtNamedElement
Sets the simple (unqualified) name of this element.- Specified by:
setSimpleName
in interfaceCtNamedElement
-
getBody
Description copied from interface:CtExecutable
Gets the body expression.- Specified by:
getBody
in interfaceCtBodyHolder
- Specified by:
getBody
in interfaceCtExecutable<T>
-
setBody
Description copied from interface:CtBodyHolder
Sets 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:
setBody
in interfaceCtBodyHolder
-
getOverriddenMethod
- Specified by:
getOverriddenMethod
in interfaceCtLambda<T>
- Returns:
- the method that this lambda expression implements. Must be defined as a non-default method in an interface, e.g. Consumer.accept().
-
getParameters
Description copied from interface:CtExecutable
Gets the parameters list.- Specified by:
getParameters
in interfaceCtExecutable<T>
-
setParameters
Description copied from interface:CtExecutable
Sets the parameters.- Specified by:
setParameters
in interfaceCtExecutable<T>
-
addParameter
Description copied from interface:CtExecutable
Add a parameter for this executable- Specified by:
addParameter
in interfaceCtExecutable<T>
- Returns:
- true if this element changed as a result of the call
-
addParameterAt
Description copied from interface:CtExecutable
Add a parameter at a specific position in the executable.- Specified by:
addParameterAt
in interfaceCtExecutable<T>
- 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:CtExecutable
Remove a parameter for this executable- Specified by:
removeParameter
in interfaceCtExecutable<T>
- Returns:
- true if this element changed as a result of the call
-
getThrownTypes
Description copied from interface:CtExecutable
Returns the exceptions and other throwables listed in this method or constructor's throws clause.- Specified by:
getThrownTypes
in interfaceCtExecutable<T>
-
setThrownTypes
public <C extends CtExecutable<T>> C setThrownTypes(Set<CtTypeReference<? extends Throwable>> thrownTypes)Description copied from interface:CtExecutable
Sets the thrown types.- Specified by:
setThrownTypes
in interfaceCtExecutable<T>
- Specified by:
setThrownTypes
in interfaceCtLambda<T>
-
addThrownType
Description copied from interface:CtExecutable
add a thrown type.- Specified by:
addThrownType
in interfaceCtExecutable<T>
- Returns:
- true if this element changed as a result of the call
-
removeThrownType
Description copied from interface:CtExecutable
remove a thrown type.- Specified by:
removeThrownType
in interfaceCtExecutable<T>
- Returns:
- true if this element changed as a result of the call
-
getSignature
Description copied from interface:CtExecutable
Gets 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:
getSignature
in interfaceCtExecutable<T>
-
getReference
Description copied from interface:CtNamedElement
Returns the corresponding reference.- Specified by:
getReference
in interfaceCtExecutable<T>
- Specified by:
getReference
in interfaceCtNamedElement
-
getExpression
Description copied from interface:CtLambda
Gets the expression in the body. Null if the body is a list of statements.- Specified by:
getExpression
in interfaceCtLambda<T>
-
setExpression
Description copied from interface:CtLambda
Sets the expression in the body of the lambda. Nothing will change if the lambda already has a value in the body attribute.- Specified by:
setExpression
in interfaceCtLambda<T>
-
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 interfaceCtCodeElement
- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtExecutable<T>
- Specified by:
clone
in interfaceCtExpression<T>
- Specified by:
clone
in interfaceCtLambda<T>
- Specified by:
clone
in interfaceCtNamedElement
- Overrides:
clone
in classCtExpressionImpl<T>
-
setType
Description copied from interface:CtTypedElement
Sets this element's type.- Specified by:
setType
in interfaceCtTypedElement<T>
- Overrides:
setType
in classCtExpressionImpl<T>
-