Interface CtLambda<T>

  • Type Parameters:
    T - created type
    All Superinterfaces:
    java.lang.Cloneable, CtBodyHolder, CtCodeElement, CtElement, CtExecutable<T>, CtExpression<T>, CtNamedElement, CtQueryable, CtTypedElement<T>, CtVisitable, FactoryAccessor,, SourcePositionHolder, TemplateParameter<T>
    All Known Implementing Classes:

    public interface CtLambda<T>
    extends CtExpression<T>, CtExecutable<T>
    This code element represents the creation of a lambda. A lambda can have two sorts of body : an simple expression or a block of statements. The usage of this concept in this class is:
         java.util.List l = new java.util.ArrayList();
           x -> { return x.toString(); } // a lambda
    • If your lambda has an expression, getBody method will return null and getExpression method will return a CtExpression.
    • If your lambda has a block of statement, getExpression method will return null and getBody will returns a CtBlock with all statements.
    So keep this in mind when you would like the body of a CtLambda.
    • Method Detail

      • getExpression

        CtExpression<T> getExpression()
        Gets the expression in the body. Null if the body is a list of statements.
      • getOverriddenMethod

        <R> CtMethod<R> getOverriddenMethod()
        the method that this lambda expression implements. Must be defined as a non-default method in an interface, e.g. Consumer.accept().
      • setExpression

        <C extends CtLambda<T>> C setExpression​(CtExpression<T> expression)
        Sets the expression in the body of the lambda. Nothing will change if the lambda already has a value in the body attribute.