Class RepeatTask<C extends FlowContext>

java.lang.Object
org.jboss.elemento.flow.RepeatTask<C>
Type Parameters:
C - the type of the context shared between tasks
All Implemented Interfaces:
Task<C>

public class RepeatTask<C extends FlowContext> extends Object implements Task<C>
A task implementation that executes a task as long as certain conditions are met.

This implementation makes it easy to nest the execution of asynchronous tasks inside a call to Flow.parallel(FlowContext, List), Flow.sequential(FlowContext, List) or Flow.repeat(FlowContext, Task).

  • Constructor Summary

    Constructors
    Constructor
    Description
    RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout)
    Creates a new task that executes the given tasks as long as the given predicate evaluates to true.
    RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations)
    Creates a new task that executes the given tasks as long as the given predicate evaluates to true.
    RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout)
    Creates a new task that executes the given tasks as long as the given predicate evaluates to true.
    RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations)
    Creates a new task that executes the given tasks as long as the given predicate evaluates to true.
  • Method Summary

    Modifier and Type
    Method
    Description
    elemental2.promise.Promise<C>
    apply(C context)
    Executes the task.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RepeatTask

      public RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout)
      Creates a new task that executes the given tasks as long as the given predicate evaluates to true.

      The task re-uses the context from the outer call to Flow.parallel(FlowContext, List), Flow.sequential(FlowContext, List) or Flow.repeat(FlowContext, Task).

      Parameters:
      task - the task to execute while the predicate evaluates to true
      predicate - the predicate used to decide whether to continue or break the loop
      failFast - whether the execution of the list should fail fast or fail last
      interval - the interval between the iterations
      timeout - the timeout for the while loop
    • RepeatTask

      public RepeatTask(Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations)
      Creates a new task that executes the given tasks as long as the given predicate evaluates to true.

      The task re-uses the context from the outer call to Flow.parallel(FlowContext, List), Flow.sequential(FlowContext, List) or Flow.repeat(FlowContext, Task).

      Parameters:
      task - the task to execute while the predicate evaluates to true
      predicate - the predicate used to decide whether to continue or break the loop
      failFast - whether the execution of the list should fail fast or fail last
      interval - the interval between the iterations
      timeout - the timeout for the while loop
      iterations - the maximal iterations the loop
    • RepeatTask

      public RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout)
      Creates a new task that executes the given tasks as long as the given predicate evaluates to true.

      The task uses the given context for the execution of the task.

      Parameters:
      context - the context shared between the iterations
      task - the task to execute while the predicate evaluates to true
      predicate - the predicate used to decide whether to continue or break the loop
      failFast - whether the execution of the list should fail fast or fail last
      interval - the interval between the iterations
      timeout - the timeout for the while loop
      iterations - the maximal iterations the loop
    • RepeatTask

      public RepeatTask(C context, Task<C> task, Predicate<C> predicate, boolean failFast, long interval, long timeout, int iterations)
      Creates a new task that executes the given tasks as long as the given predicate evaluates to true.

      The task uses the given context for the execution of the task.

      Parameters:
      context - the context shared between the iterations
      task - the task to execute while the predicate evaluates to true
      predicate - the predicate used to decide whether to continue or break the loop
      failFast - whether the execution of the list should fail fast or fail last
      interval - the interval between the iterations
      timeout - the timeout for the while loop
      iterations - the maximal iterations the loop
  • Method Details

    • apply

      public elemental2.promise.Promise<C> apply(C context)
      Description copied from interface: Task
      Executes the task.
      Specified by:
      apply in interface Task<C extends FlowContext>
      Parameters:
      context - the context shared between tasks
      Returns:
      a promise containing the shared context