- All Known Subinterfaces:
AnonymousClassCreator,LambdaCreator
A creator for an entity which can capture values from an enclosing scope.
-
Method Summary
-
Method Details
-
capture
Capture an enclosing value as a variable so that it may be used in the lambda body. All values that are created outside the lambda must be captured into new variables (eventhis) in order to be used within the lambda, otherwise a generation-time exception may be thrown.If the given expression is a variable, the given name overrides the variable's name within the scope of the lambda.
Names of captured variables must be unique for each anonymous class / lambda.
- Parameters:
name- the name of the variable (must not benull)value- the capture value (must not benull)- Returns:
- the captured variable (not
null)
-
capture
Capture an enclosing variable so that it may be used in the lambda body.Name of the variable is used unchanged. Note that names of captured variables must be unique for each anonymous class / lambda.
- Parameters:
outer- the enclosing variable to capture (must not benull)- Returns:
- the captured variable (not
null)
-