Class FlowController

java.lang.Object
ch.nolix.base.programcontrol.flowcontrol.FlowController

public final class FlowController extends Object
The FlowController provides methods for flow control. Of the FlowController an instance cannot be created.
Author:
Silvan Wyss
  • Method Details

    • asLongAs

      public static IAsLongAsMediator asLongAs(BooleanSupplier condition)
      Parameters:
      condition -
      Returns:
      a new IAsLongAsMediator with the given condition.
      Throws:
      RuntimeException - if the given condition is null.
    • asSoonAs

      public static IAsSoonAsMediator asSoonAs(BooleanSupplier condition)
      Parameters:
      condition -
      Returns:
      a new IAsSoonAsMediator with the given condition.
      Throws:
      RuntimeException - if the given condition is null.
    • asSoonAsNoMore

      public static IAsSoonAsMediator asSoonAsNoMore(BooleanSupplier condition)
      Parameters:
      condition -
      Returns:
      a new IAsSoonAsMediator with the negation of the given condition.
      Throws:
      RuntimeException - if the given condition is null.
    • enqueue

      public static IFuture enqueue(Runnable job)
      Enqueues the given job.
      Parameters:
      job -
      Returns:
      a IFuture for the given job.
      Throws:
      RuntimeException - if the given job is null.
    • forCount

      public static IForCountMediator forCount(int maxRunCount)
      Parameters:
      maxRunCount -
      Returns:
      a new IForCountMediator with the given maxRunCount.
      Throws:
      RuntimeException - if the given maxRunCount is negative.
    • forMaxMilliseconds

      public static IForMaxMillisecondsMediator forMaxMilliseconds(int maxDurationInMilliseconds)
      Parameters:
      maxDurationInMilliseconds -
      Returns:
      a new IForMaxMillisecondsMediator for the given maxDurationInMilliseconds.
      Throws:
      RuntimeException - if the given maxDurationInMilliseconds is negative.
    • forMaxSeconds

      public static IForMaxMillisecondsMediator forMaxSeconds(int maxDurationInSeconds)
      Parameters:
      maxDurationInSeconds -
      Returns:
      a new IForMaxMillisecondsMediator for the given maxDurationInSeconds.
      Throws:
      RuntimeException - if the given maxDurationInSeconds is negative.
    • runInBackground

      public static IFuture runInBackground(Runnable job)
      Runs the given job in background.
      Parameters:
      job -
      Returns:
      a new IFuture for the execution of the given job.
      Throws:
      RuntimeException - if the given job is null.
    • runInBackgroundAndOrder

      public static IFuture runInBackgroundAndOrder(Runnable... jobs)
      Runs the given jobs in background in the given order.
      Parameters:
      jobs -
      Returns:
      a new IFuture for the execution of the given jobs.
    • runInBackground

      public static <R> IResultFuture<R> runInBackground(Supplier<R> resultJob)
      Runs the given result job in background. A result job is a job that returns a result.
      Type Parameters:
      R - is the type of the result of the given resultJob.
      Parameters:
      resultJob -
      Returns:
      a new IResultFuture for the execution of the given resultJob.
      Throws:
      RuntimeException - if the given resultJob is null.
    • runInEnclosedMode

      public static void runInEnclosedMode(Runnable job)
      Runs the given job in an enclosed mode. Prints out the stack trace of any occurring error. An error will occur it the given job is null or if the given job will not run properly.
      Parameters:
      job -
    • runInEnclosedModeAndGetSuccessFlag

      public static boolean runInEnclosedModeAndGetSuccessFlag(Runnable job)
      Runs the given job in an enclosed mode. Prints out the stack trace of any occurring error. An error will occur it the given job is null or if the given job will not run properly.
      Parameters:
      job -
      Returns:
      true if the given job runs successfully, false otherwise.
    • until

      public static IAsLongAsMediator until(BooleanSupplier condition)
      Parameters:
      condition -
      Returns:
      a new IAsLongAsMediator for the negation of the given condition.
      Throws:
      RuntimeException - if the given condition is null.
    • waitAsLongAs

      public static IWaitMediator waitAsLongAs(BooleanSupplier condition)
      Waits as long as the given condition is fulfilled.
      Parameters:
      condition -
      Returns:
      a IWaitMediator.
      Throws:
      RuntimeException - if the given condition is null.
    • waitForMilliseconds

      public static IWaitMediator waitForMilliseconds(int durationInMilliseconds)
      Waits for the given durationInMilliseconds.
      Parameters:
      durationInMilliseconds -
      Returns:
      a new IWaitMediator.
      Throws:
      RuntimeException - if the given durationInMilliseconds is negative.
    • waitForSeconds

      public static IWaitMediator waitForSeconds(int durationInSeconds)
      Waits for the given durationInSeconds.
      Parameters:
      durationInSeconds -
      Returns:
      a new IWaitMediator.
      Throws:
      RuntimeException - if the given durationInSeconds is negative.
    • waitUntil

      public static IWaitMediator waitUntil(BooleanSupplier condition)
      Waits until the given condition is fulfilled.
      Parameters:
      condition -
      Returns:
      a new IWaitMediator.
      Throws:
      RuntimeException - if the given condition is null.