Record Class NestedPlan<C>

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

public record NestedPlan<C>(List<Plan<C>> parallelPlans) extends Record implements SimplyComposedPlan<C>
  • Constructor Summary

    Constructors
    Constructor
    Description
    NestedPlan(List<Plan<C>> parallelPlans)
    Creates an instance of a NestedPlan record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    and(Plan<C> plan)
    Create a new plan that executes this plan and the given plan in parallel.
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    execute(TaskExecutor taskExecutor, C context, Runnable onCompletion)
    Submit this plan for execution.
    final int
    Returns a hash code value for this object.
    static <C> NestedPlan<C>
    of(Plan<C>... plans)
     
    Returns the value of the parallelPlans record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface dev.engine_room.flywheel.api.task.Plan

    execute

    Methods inherited from interface dev.engine_room.flywheel.lib.task.SimplyComposedPlan

    then
  • Constructor Details

    • NestedPlan

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

    • of

      @SafeVarargs public static <C> NestedPlan<C> of(Plan<C>... plans)
    • 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.
    • parallelPlans

      public List<Plan<C>> parallelPlans()
      Returns the value of the parallelPlans record component.
      Returns:
      the value of the parallelPlans record component