L - The type of AtlanticLambda to handle.RESULT - The type of result returned by the execution.public class ExecutionBuilder<L extends AtlanticLambda,RESULT> extends Object
AtlanticLambda and works it's way down by adding parameters
to it and converting into the next type of ExecutionBuilder that handles the AtlanticLambda with one less
parameter. This ends when there are no more parameters and the last ExecutionBuilder, an instance of
FunctionExecutionBuilder or SupplierExecutionBuilder, gets the
Executor from the ExecutionContext and executes the
lambda on it.
An example of how ExecutionBuilders work is the following:
TriFunctionExecutionBuilder<MyParam1Type, MyParam2Type, MyParam3Type, MyResultType, MyResultType> original = new TriFunctionExecutionBuilder<>(MyClass::staticMethodWith3Params, new ArrayList<>(), Parser.self(), myExecutionContext);
FunctionExecutionBuilder<MyParam2Type, MyParam3Type, MyResultType, MyResultType> next = new TriFunctionExecutionBuilder<>(MyClass::staticMethodWith3Params, new ArrayList<>(), Parser.self(), myExecutionContext).withParam(param1);
FunctionExecutionBuilder<MyParam3Type, MyResultType, MyResultType> last = next.withParam(param2);
MyResultType result = last.withParam(param3);
To simplify that block of code, the use is the following:
MyResultType result = new TriFunctionExecutionBuilder<>(MyClass::staticMethodWith3Params, new ArrayList<>(), Parser.self(), myExecutionContext).withParam(param1)
.withParam(param2)
.withParam(param3);
This class also contains an ExecutionContext, which will provide functionality over the execution of the
lambda.ExecutionContext| Modifier | Constructor and Description |
|---|---|
protected |
ExecutionBuilder(L lambda,
List<Object> params,
ExecutionContext<RESULT> context)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected ExecutionContext<RESULT> |
getContext()
Gets the
ExecutionContext that contains all the listeners and handlers of the execution. |
protected L |
getLambda()
Gets the
AtlanticLambda to execute. |
protected List<Object> |
getParams()
Gets the list of parameters accumulated for the execution.
|
protected ExecutionBuilder(L lambda, List<Object> params, ExecutionContext<RESULT> context)
lambda - The AtlanticLambda to execute.params - The parameters already accumulated when creating this ExecutionBuilder.context - The ExecutionContext that contains all the listeners and handlers of the execution.protected L getLambda()
AtlanticLambda to execute.protected List<Object> getParams()
protected ExecutionContext<RESULT> getContext()
ExecutionContext that contains all the listeners and handlers of the execution.Copyright © 2019. All rights reserved.