Class 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>

public class CtLambdaImpl<T> extends CtExpressionImpl<T> implements CtLambda<T>
See Also:
Serialized Form
  • Constructor Details

    • CtLambdaImpl

      public CtLambdaImpl()
  • Method Details

    • accept

      public void accept(CtVisitor visitor)
      Description copied from interface: CtVisitable
      Accepts a visitor
      Specified by:
      accept in interface CtVisitable
    • getSimpleName

      public String getSimpleName()
      Description copied from interface: CtNamedElement
      Returns the simple (unqualified) name of this element.
      Specified by:
      getSimpleName in interface CtNamedElement
    • setSimpleName

      public <C extends CtNamedElement> C setSimpleName(String simpleName)
      Description copied from interface: CtNamedElement
      Sets the simple (unqualified) name of this element.
      Specified by:
      setSimpleName in interface CtNamedElement
    • getBody

      public CtBlock<T> getBody()
      Description copied from interface: CtExecutable
      Gets the body expression.
      Specified by:
      getBody in interface CtBodyHolder
      Specified by:
      getBody in interface CtExecutable<T>
    • setBody

      public <C extends CtBodyHolder> C setBody(CtStatement statement)
      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 interface CtBodyHolder
    • getOverriddenMethod

      public <R> CtMethod<R> getOverriddenMethod()
      Specified by:
      getOverriddenMethod in interface CtLambda<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

      public List<CtParameter<?>> getParameters()
      Description copied from interface: CtExecutable
      Gets the parameters list.
      Specified by:
      getParameters in interface CtExecutable<T>
    • setParameters

      public <C extends CtExecutable<T>> C setParameters(List<CtParameter<?>> params)
      Description copied from interface: CtExecutable
      Sets the parameters.
      Specified by:
      setParameters in interface CtExecutable<T>
    • addParameter

      public <C extends CtExecutable<T>> C addParameter(CtParameter<?> parameter)
      Description copied from interface: CtExecutable
      Add a parameter for this executable
      Specified by:
      addParameter in interface CtExecutable<T>
      Returns:
      true if this element changed as a result of the call
    • addParameterAt

      public <C extends CtExecutable<T>> C addParameterAt(int position, CtParameter<?> parameter)
      Description copied from interface: CtExecutable
      Add a parameter at a specific position in the executable.
      Specified by:
      addParameterAt in interface CtExecutable<T>
      Parameters:
      position - index where the `parameter` needs to be inserted
      parameter - parameter to be inserted
      Returns:
      an object or sub-type of CtExecutable
    • removeParameter

      public boolean removeParameter(CtParameter<?> parameter)
      Description copied from interface: CtExecutable
      Remove a parameter for this executable
      Specified by:
      removeParameter in interface CtExecutable<T>
      Returns:
      true if this element changed as a result of the call
    • getThrownTypes

      public Set<CtTypeReference<? extends Throwable>> 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 interface CtExecutable<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 interface CtExecutable<T>
      Specified by:
      setThrownTypes in interface CtLambda<T>
    • addThrownType

      public <C extends CtExecutable<T>> C addThrownType(CtTypeReference<? extends Throwable> throwType)
      Description copied from interface: CtExecutable
      add a thrown type.
      Specified by:
      addThrownType in interface CtExecutable<T>
      Returns:
      true if this element changed as a result of the call
    • removeThrownType

      public boolean removeThrownType(CtTypeReference<? extends Throwable> throwType)
      Description copied from interface: CtExecutable
      remove a thrown type.
      Specified by:
      removeThrownType in interface CtExecutable<T>
      Returns:
      true if this element changed as a result of the call
    • getSignature

      public String getSignature()
      Description copied from interface: CtExecutable
      Gets the signature of this method or constructor. The signature is composed of the method name and the parameter types, all fully-qualified, eg "int 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 https://stackoverflow.com/questions/16149285/does-a-methods-signature-in-java-include-its-return-type see https://en.wikipedia.org/wiki/Type_signature
      Specified by:
      getSignature in interface CtExecutable<T>
    • getReference

      public CtExecutableReference<T> getReference()
      Description copied from interface: CtNamedElement
      Returns the corresponding reference.
      Specified by:
      getReference in interface CtExecutable<T>
      Specified by:
      getReference in interface CtNamedElement
    • getExpression

      public CtExpression<T> 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 interface CtLambda<T>
    • setExpression

      public <C extends CtLambda<T>> C setExpression(CtExpression<T> expression)
      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 interface CtLambda<T>
    • clone

      public CtLambda<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 methods Refactoring.copyType(CtType) and Refactoring.copyMethod(CtMethod) instead which does additional work beyond cloning.
      Specified by:
      clone in interface CtCodeElement
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtExecutable<T>
      Specified by:
      clone in interface CtExpression<T>
      Specified by:
      clone in interface CtLambda<T>
      Specified by:
      clone in interface CtNamedElement
      Overrides:
      clone in class CtExpressionImpl<T>
    • setType

      public <C extends CtTypedElement> C setType(CtTypeReference<T> type)
      Description copied from interface: CtTypedElement
      Sets this element's type.
      Specified by:
      setType in interface CtTypedElement<T>
      Overrides:
      setType in class CtExpressionImpl<T>