All Known Implementing Classes:
LambdaSpecImpl

@ClassVersion(sourceVersion="$Id: LambdaSpec.java 1085 2024-01-05 16:23:28Z tquadrat $") @API(status=STABLE, since="0.0.5") public sealed interface LambdaSpec permits LambdaSpecImpl

The specification for a generated lambda construct.

Parameters and Types

When adding more than one parameter, all of them must have a specified type or none of them may have one, leaving the compiler to infer the type. As paramterBuilder() does require a type, we take Primitives.VOID instead of a concrete type if we want to get the type being inferred.

Formatting

Basically, a lambda expression has two different formats, one without curly braces

  a -> modify( a )

and the other with with curly braces, requiring a return statement:

  a ->
  {
      modify( a );
      return a.result;
  }

The body of the second form usually has more than one statement.

JavaComposer emits the first form when only one of the methods

is called only once on the builder instance. The second form is forced, when one of the methods above is called again, or when one of the methods

is called.

There is no validation on the code; this means it is in the caller's responsibility to ensure that there is a return statement in the second case.

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: LambdaSpec.java 1085 2024-01-05 16:23:28Z tquadrat $
Since:
0.0.5
UML Diagram
UML Diagram for "org.tquadrat.foundation.javacomposer.LambdaSpec"

UML Diagram for "org.tquadrat.foundation.javacomposer.LambdaSpec"

UML Diagram for "org.tquadrat.foundation.javacomposer.LambdaSpec"