Class TaskOutput<T>
- All Implemented Interfaces:
Supplier<T>
Task outputs may be declared as computed, indicating that their output is set as a result of the task being executed.
Task outputs may be derived from the values in other inputs or outputs, these are always resolved and set before the Output's task is executed.
Created by covers1624 on 6/26/25.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescription<A> voidderiveFrom(TaskIO<? extends A> aIo, Function<? super A, ? extends T> func) Derive this output's value from the input or output of another task, with the given function applied to the result.<A,B> void deriveFrom(TaskIO<? extends A> aIo, TaskIO<? extends B> bIo, BiFunction<? super A, ? super B, ? extends T> func) Derive this output's value from multiple inputs and/or outputs of other tasks, with the given function applied to the result.get()Get the value stored in this output now.Get the future for this tasks output.booleanvoidSet the value of this output.
-
Method Details
-
getFuture
Get the future for this tasks output.This future will only complete once this outputs task has completed.
-
get
Get the value stored in this output now.This will not wait for the task to be complete, and should be used by tasks internally.
This can only be used by outputs which are not
isComputedor have had their value set.- Returns:
- The value in this output.
-
set
Set the value of this output.It is illegal to override the output if the task has already been scheduled, and this output is not
isComputed.- Parameters:
value- The value.
-
deriveFrom
Derive this output's value from the input or output of another task, with the given function applied to the result.Derived outputs are always resolved before the current task is run. If you provide Inputs for derivation it will not mark the task they are from as a dependency, only any task that input depends on will be marked dependencies. Conversely, if you provide an output, that task will become a dependency.
- Parameters:
aIo- The IO to derive from.func- The function to apply
-
deriveFrom
public <A,B> void deriveFrom(TaskIO<? extends A> aIo, TaskIO<? extends B> bIo, BiFunction<? super A, ? super B, ? extends T> func) Derive this output's value from multiple inputs and/or outputs of other tasks, with the given function applied to the result.Derived outputs are always resolved before the current task is run. If you provide Inputs for derivation it will not mark the task they are from as a dependency, only any task that input depends on will be marked dependencies. Conversely, if you provide an output, that task will become a dependency.
- Parameters:
aIo- The IO to derive from.func- The function to apply
-
isComputed
public boolean isComputed()- Returns:
- If this task output value is set when the task executes.
-