Record Class SimplePlan<C>

java.lang.Object
java.lang.Record
dev.engine_room.flywheel.lib.task.SimplePlan<C>
All Implemented Interfaces:
Plan<C>, SimplyComposedPlan<C>

public record SimplePlan<C>(List<RunnableWithContext<C>> parallelTasks) extends Record implements SimplyComposedPlan<C>
  • Constructor Details

    • SimplePlan

      public SimplePlan(List<RunnableWithContext<C>> parallelTasks)
      Creates an instance of a SimplePlan record class.
      Parameters:
      parallelTasks - the value for the parallelTasks record component
  • Method Details

    • of

      @SafeVarargs public static <C> SimplePlan<C> of(RunnableWithContext.Ignored<C>... tasks)
    • of

      @SafeVarargs public static <C> SimplePlan<C> of(RunnableWithContext<C>... tasks)
    • of

      public static <C> SimplePlan<C> of(List<RunnableWithContext<C>> tasks)
    • execute

      public void execute(TaskExecutor taskExecutor, C context, Runnable onCompletion)
      Description copied from interface: Plan
      Submit this plan for execution.

      You must call onCompletion.run() when the plan has completed execution.

      Specified by:
      execute in interface Plan<C>
      Parameters:
      taskExecutor - The executor to use for submitting tasks.
      context - An arbitrary context object that the plan wants to use at runtime.
      onCompletion - A callback to run when the plan has completed execution, useful for chaining plans.
    • and

      public Plan<C> and(Plan<C> plan)
      Description copied from interface: Plan
      Create a new plan that executes this plan and the given plan in parallel.
      Specified by:
      and in interface Plan<C>
      Specified by:
      and in interface SimplyComposedPlan<C>
      Parameters:
      plan - The plan to execute in parallel with this plan.
      Returns:
      The composed plan.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • parallelTasks

      public List<RunnableWithContext<C>> parallelTasks()
      Returns the value of the parallelTasks record component.
      Returns:
      the value of the parallelTasks record component