Class FlowController
java.lang.Object
ch.nolix.base.programcontrol.flowcontrol.FlowController
The
FlowController provides methods for flow control.
Of the FlowController an instance cannot be created.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionstatic IAsLongAsMediatorasLongAs(BooleanSupplier condition) static IAsSoonAsMediatorasSoonAs(BooleanSupplier condition) static IAsSoonAsMediatorasSoonAsNoMore(BooleanSupplier condition) static IFutureEnqueues the given job.static IForCountMediatorforCount(int maxRunCount) static IForMaxMillisecondsMediatorforMaxMilliseconds(int maxDurationInMilliseconds) static IForMaxMillisecondsMediatorforMaxSeconds(int maxDurationInSeconds) static IFuturerunInBackground(Runnable job) Runs the given job in background.static <R> IResultFuture<R> runInBackground(Supplier<R> resultJob) Runs the given result job in background.static IFuturerunInBackgroundAndOrder(Runnable... jobs) Runs the given jobs in background in the given order.static voidRuns the given job in an enclosed mode.static booleanRuns the given job in an enclosed mode.static IAsLongAsMediatoruntil(BooleanSupplier condition) static IWaitMediatorwaitAsLongAs(BooleanSupplier condition) Waits as long as the given condition is fulfilled.static IWaitMediatorwaitForMilliseconds(int durationInMilliseconds) Waits for the given durationInMilliseconds.static IWaitMediatorwaitForSeconds(int durationInSeconds) Waits for the given durationInSeconds.static IWaitMediatorwaitUntil(BooleanSupplier condition) Waits until the given condition is fulfilled.
-
Method Details
-
asLongAs
- Parameters:
condition-- Returns:
- a new
IAsLongAsMediatorwith the given condition. - Throws:
RuntimeException- if the given condition is null.
-
asSoonAs
- Parameters:
condition-- Returns:
- a new
IAsSoonAsMediatorwith the given condition. - Throws:
RuntimeException- if the given condition is null.
-
asSoonAsNoMore
- Parameters:
condition-- Returns:
- a new
IAsSoonAsMediatorwith the negation of the given condition. - Throws:
RuntimeException- if the given condition is null.
-
enqueue
Enqueues the given job.- Parameters:
job-- Returns:
- a
IFuturefor the given job. - Throws:
RuntimeException- if the given job is null.
-
forCount
- Parameters:
maxRunCount-- Returns:
- a new
IForCountMediatorwith the given maxRunCount. - Throws:
RuntimeException- if the given maxRunCount is negative.
-
forMaxMilliseconds
- Parameters:
maxDurationInMilliseconds-- Returns:
- a new
IForMaxMillisecondsMediatorfor the given maxDurationInMilliseconds. - Throws:
RuntimeException- if the given maxDurationInMilliseconds is negative.
-
forMaxSeconds
- Parameters:
maxDurationInSeconds-- Returns:
- a new
IForMaxMillisecondsMediatorfor the given maxDurationInSeconds. - Throws:
RuntimeException- if the given maxDurationInSeconds is negative.
-
runInBackground
Runs the given job in background.- Parameters:
job-- Returns:
- a new
IFuturefor the execution of the given job. - Throws:
RuntimeException- if the given job is null.
-
runInBackgroundAndOrder
-
runInBackground
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
IResultFuturefor the execution of the given resultJob. - Throws:
RuntimeException- if the given resultJob is null.
-
runInEnclosedMode
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
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
- Parameters:
condition-- Returns:
- a new
IAsLongAsMediatorfor the negation of the given condition. - Throws:
RuntimeException- if the given condition is null.
-
waitAsLongAs
Waits as long as the given condition is fulfilled.- Parameters:
condition-- Returns:
- a
IWaitMediator. - Throws:
RuntimeException- if the given condition is null.
-
waitForMilliseconds
Waits for the given durationInMilliseconds.- Parameters:
durationInMilliseconds-- Returns:
- a new
IWaitMediator. - Throws:
RuntimeException- if the given durationInMilliseconds is negative.
-
waitForSeconds
Waits for the given durationInSeconds.- Parameters:
durationInSeconds-- Returns:
- a new
IWaitMediator. - Throws:
RuntimeException- if the given durationInSeconds is negative.
-
waitUntil
Waits until the given condition is fulfilled.- Parameters:
condition-- Returns:
- a new
IWaitMediator. - Throws:
RuntimeException- if the given condition is null.
-