public class CodeExecution<I,O> extends CoroutineStep<I,O>
Constructor and Description |
---|
CodeExecution(java.util.function.BiFunction<I,Continuation<?>,O> fCode)
Creates a new instance from a binary function that accepts the
continuation of the execution and the input value.
|
CodeExecution(java.util.function.Function<I,O> fCode)
Creates a new instance from a simple function that processes the input
into the output value.
|
Modifier and Type | Method and Description |
---|---|
static <I,O> CodeExecution<I,O> |
apply(java.util.function.BiFunction<I,Continuation<?>,O> fCode)
Applies a
BiFunction to the step input and the continuation of
the current execution and return the processed output. |
static <I,O> CodeExecution<I,O> |
apply(java.util.function.Function<I,O> fCode)
Applies a
Function to the step input and return the processed
output. |
static <T> CodeExecution<T,java.lang.Void> |
consume(java.util.function.BiConsumer<T,Continuation<?>> fCode)
Consumes the input value with a
Consumer and creates no result. |
static <T> CodeExecution<T,java.lang.Void> |
consume(java.util.function.Consumer<T> fCode)
Consumes the input value with a
Consumer and creates no result. |
protected O |
execute(I rInput,
Continuation<?> rContinuation)
This method must be implemented by subclasses to provide the actual
functionality of this step.
|
static <I,O> CodeExecution<I,O> |
getParameter(org.obrel.core.RelationType<O> rSource)
Queries a parameter relation from the
Continuation and returns it
as the result of the execution. |
static <I,O> CodeExecution<I,O> |
getScopeParameter(org.obrel.core.RelationType<O> rSource)
Queries a parameter relation from the
CoroutineScope and returns
it as the result of the execution. |
static <T> CodeExecution<T,T> |
run(java.util.function.Consumer<Continuation<?>> fCode)
Executes a
Runnable , ignoring any input value and returning no
result. |
static <T> CodeExecution<T,java.lang.Void> |
run(java.lang.Runnable fCode)
Executes a
Runnable , ignoring any input value and returning no
result. |
static <T> CodeExecution<T,T> |
setParameter(org.obrel.core.RelationType<T> rTarget)
Sets the input value into a parameter of the
Continuation and
then returns it. |
static <T> CodeExecution<T,T> |
setScopeParameter(org.obrel.core.RelationType<T> rTarget)
Sets the input value into a parameter of the
CoroutineScope and
then returns it. |
static <I,O> CodeExecution<I,O> |
supply(java.util.function.Function<Continuation<?>,O> fCode)
Provides a value from a
Supplier as the result, ignoring any
input value. |
static <I,O> CodeExecution<I,O> |
supply(java.util.function.Supplier<O> fCode)
Provides a value from a
Supplier as the result, ignoring any
input value. |
fail, runAsync, runBlocking, terminateCoroutine, toString
deleteRelation, get, getRelation, getRelations, notifyRelationListeners, readRelations, relationsEqual, relationsHashCode, relationsString, set, set, transform, writeRelations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public CodeExecution(java.util.function.BiFunction<I,Continuation<?>,O> fCode)
fCode
- A binary function containing the code to be executedpublic static <I,O> CodeExecution<I,O> apply(java.util.function.Function<I,O> fCode)
Function
to the step input and return the processed
output.fCode
- The function to be executedpublic static <I,O> CodeExecution<I,O> apply(java.util.function.BiFunction<I,Continuation<?>,O> fCode)
BiFunction
to the step input and the continuation of
the current execution and return the processed output.fCode
- The binary function to be executedpublic static <T> CodeExecution<T,java.lang.Void> consume(java.util.function.Consumer<T> fCode)
Consumer
and creates no result.fCode
- The consumer to be executedpublic static <T> CodeExecution<T,java.lang.Void> consume(java.util.function.BiConsumer<T,Continuation<?>> fCode)
Consumer
and creates no result.fCode
- The consumer to be executedpublic static <I,O> CodeExecution<I,O> getParameter(org.obrel.core.RelationType<O> rSource)
Continuation
and returns it
as the result of the execution.rSource
- The relation type of the parameterpublic static <I,O> CodeExecution<I,O> getScopeParameter(org.obrel.core.RelationType<O> rSource)
CoroutineScope
and returns
it as the result of the execution.rSource
- The relation type of the parameterpublic static <T> CodeExecution<T,java.lang.Void> run(java.lang.Runnable fCode)
Runnable
, ignoring any input value and returning no
result.fCode
- The runnable to be executedpublic static <T> CodeExecution<T,T> run(java.util.function.Consumer<Continuation<?>> fCode)
Runnable
, ignoring any input value and returning no
result.fCode
- The runnable to be executedpublic static <T> CodeExecution<T,T> setParameter(org.obrel.core.RelationType<T> rTarget)
Continuation
and
then returns it.rTarget
- The type of the relation to set the parameter inpublic static <T> CodeExecution<T,T> setScopeParameter(org.obrel.core.RelationType<T> rTarget)
CoroutineScope
and
then returns it.rTarget
- The type of the relation to set the parameter inpublic static <I,O> CodeExecution<I,O> supply(java.util.function.Supplier<O> fCode)
Supplier
as the result, ignoring any
input value.fCode
- The supplier to be executedpublic static <I,O> CodeExecution<I,O> supply(java.util.function.Function<Continuation<?>,O> fCode)
Supplier
as the result, ignoring any
input value.fCode
- The supplier to be executedprotected O execute(I rInput, Continuation<?> rContinuation)
execute
in class CoroutineStep<I,O>
rInput
- The input valuerContinuation
- The continuation of the execution