Class TaskInput<T>

java.lang.Object
net.javasauce.ss.util.task.TaskIO<T>
net.javasauce.ss.util.task.TaskInput<T>
All Implemented Interfaces:
Supplier<T>
Direct Known Subclasses:
TaskInput.Collection

public sealed class TaskInput<T> extends TaskIO<T> permits TaskInput.Collection<E>
An input for a Task, these are represented as lazy futures.

Inputs may be defined as a static known value, or defined as the output of another task.

Created by covers1624 on 6/26/25.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    An input which can represent multiple things, and multiple dependencies.
  • Field Summary

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

    task
  • Method Summary

    Modifier and Type
    Method
    Description
    <A> void
    deriveFrom(TaskIO<A> aIo, Function<? super A,? extends T> func)
    Derive this input's value from the input or output of another task, with the given function applied to the result.
    <A, B> void
    deriveFrom(TaskIO<A> aIo, TaskIO<B> bIo, BiFunction<? super A,? super B,? extends T> func)
    Derive this input'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 Input.
    Compute the future for this Input, including any tasks required to read the input.
    protected final void
    set(Supplier<CompletableFuture<T>> futureSupplier)
    Set the future supplier for this Input.
    void
    set(TaskIO<T> io)
    Set the value of this input to be the value of another input or output.
    void
    set(T value)
    Set the vlue of this input to a static value.

    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()
      Compute the future for this Input, including any tasks required to read the input.
      Specified by:
      getFuture in class TaskIO<T>
      Returns:
      The future for this input.
    • get

      public T get()
      Get the value stored in this Input.

      Will block until the inputs future is completed.

      Returns:
      The vlaue.
    • set

      public void set(T value)
      Set the vlue of this input to a static value.

      It is illegal to override a task Input, if the task has already been scheduled.

      Parameters:
      value - The value.
    • set

      public void set(TaskIO<T> io)
      Set the value of this input to be the value of another input or output.

      If provided an Input of another task, this will copy the inputs requirements. If provided an output of another task, the other task will be marked as a dependency.

      It is illegal to override a task Input, if the task has already been scheduled.

      Parameters:
      io - The IO to set this input from.
    • deriveFrom

      public <A> void deriveFrom(TaskIO<A> aIo, Function<? super A,? extends T> func)
      Derive this input's value from the input or output of another task, with the given function applied to the result.

      If provided an Input of another task, this will copy the inputs requirements. If provided an output of another task, this other task will be marked as a dependency.

      Parameters:
      aIo - The IO to derive from.
      func - The function to apply
    • deriveFrom

      public <A, B> void deriveFrom(TaskIO<A> aIo, TaskIO<B> bIo, BiFunction<? super A,? super B,? extends T> func)
      Derive this input's value from multiple inputs and/or outputs of other tasks, with the given function applied to the result.

      If provided an Input of another task, this will copy the inputs requirements. If provided an output of another task, this other task will be marked as a dependency.

      Parameters:
      aIo - The first IO to derive from.
      bIo - The second IO to derive from.
      func - The function to apply
    • set

      protected final void set(Supplier<CompletableFuture<T>> futureSupplier)
      Set the future supplier for this Input.

      We use suppliers to avoid resolving the future until the task builds its own future, preventing execution of dependencies until our task is scheduled.

      It is illegal to override a task Input, if the task has already been scheduled.

      Parameters:
      futureSupplier - The supplier to provide the future for this IO's value.