Class TaskOutput<T>

java.lang.Object
net.javasauce.ss.util.task.TaskIO<T>
net.javasauce.ss.util.task.TaskOutput<T>
All Implemented Interfaces:
Supplier<T>

public final class TaskOutput<T> extends TaskIO<T>
An output for a task.

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

    Fields inherited from class net.javasauce.ss.util.task.TaskIO

    task
  • Method Summary

    Modifier and Type
    Method
    Description
    <A> void
    deriveFrom(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.
    boolean
     
    void
    set(T value)
    Set the value of this output.

    Methods inherited from class net.javasauce.ss.util.task.TaskIO

    getName, getTask

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getFuture

      public CompletableFuture<T> getFuture()
      Get the future for this tasks output.

      This future will only complete once this outputs task has completed.

      Specified by:
      getFuture in class TaskIO<T>
      Returns:
      The future for this output.
    • get

      public T 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 isComputed or have had their value set.

      Returns:
      The value in this output.
    • set

      public void set(T value)
      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

      public <A> void deriveFrom(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.

      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.