Class JobExecutor
java.lang.Object
java.lang.Thread
ch.nolix.base.programcontrol.flowcontrol.JobExecutor
- All Implemented Interfaces:
Runnable
- Author:
- Silvan Wyss
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic JobExecutorforJobs(IContainer<Runnable> jobs) static JobExecutorstatic JobExecutorstatic JobExecutorforStepAndMaxStepRunCount(Runnable step, int maxStepRunCount) static JobExecutorforStepAndMaxStepRunCountAndDelayBetweenStepRunsInMilliseconds(Runnable step, int maxStepRunCount, int delayBetweenStepRunsInMilliseconds) static JobExecutorforStepAndMaxStepRunCountAndNextStepRunCondition(Runnable step, int maxStepRunCount, BooleanSupplier nextStepRunCondition) static JobExecutorforStepAndMaxStepRunCountAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds(Runnable step, int maxStepRunCount, BooleanSupplier nextStepRunCondition, int delayBetweenStepRunsInMilliseconds) static JobExecutorforStepAndNextStepRunCondition(Runnable step, BooleanSupplier nextStepRunCondition) static JobExecutorforStepAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds(Runnable step, BooleanSupplier nextStepRunCondition, int delayBetweenStepRunsInMilliseconds) getError()intbooleanbooleanbooleanbooleanbooleanbooleanvoidrun()Lets the currentJobExecutorrun.Methods inherited from class Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Method Details
-
forStep
- Parameters:
step-- Returns:
- a new
JobExecutorwith the given step. - Throws:
RuntimeException- if the given step is null.
-
forStepAndMaxStepRunCount
- Parameters:
step-maxStepRunCount-- Returns:
- a new
JobExecutorwith the given step and maxStepRunCount. - Throws:
RuntimeException- if the given step is null.RuntimeException- if the given maxStepRunCount is negative.
-
forStepAndMaxStepRunCountAndDelayBetweenStepRunsInMilliseconds
public static JobExecutor forStepAndMaxStepRunCountAndDelayBetweenStepRunsInMilliseconds(Runnable step, int maxStepRunCount, int delayBetweenStepRunsInMilliseconds) - Parameters:
step-maxStepRunCount-delayBetweenStepRunsInMilliseconds-- Returns:
- a new
JobExecutorwith the given step, maxStepRunCount and delayBetweenStepRunsInMilliseconds. - Throws:
RuntimeException- if the given step is null.RuntimeException- if the given maxStepRunCount is negative.RuntimeException- if the given delayBetweenStepRunsInMilliseconds is negative.
-
forStepAndMaxStepRunCountAndNextStepRunCondition
public static JobExecutor forStepAndMaxStepRunCountAndNextStepRunCondition(Runnable step, int maxStepRunCount, BooleanSupplier nextStepRunCondition) - Parameters:
step-maxStepRunCount-nextStepRunCondition-- Returns:
- a new
JobExecutorwith the given step, maxStepRunCount and nextStepRunCondition. - Throws:
RuntimeException- if the given step is null.RuntimeException- if the given maxStepRunCount is negative.RuntimeException- if the given nextStepRunCondition is null.
-
forStepAndMaxStepRunCountAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds
public static JobExecutor forStepAndMaxStepRunCountAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds(Runnable step, int maxStepRunCount, BooleanSupplier nextStepRunCondition, int delayBetweenStepRunsInMilliseconds) - Parameters:
step-maxStepRunCount-nextStepRunCondition-delayBetweenStepRunsInMilliseconds-- Returns:
- a new
JobExecutorwith the given step, maxStepRunCount, nextStepRunCondition and delayBetweenStepRunsInMilliseconds. - Throws:
RuntimeException- if the given job is null.RuntimeException- if the given maxRunCount is negative.RuntimeException- if the given condition is null.RuntimeException- if the given delayBetweenStepRunsInMilliseconds is negative.
-
forStepAndNextStepRunCondition
public static JobExecutor forStepAndNextStepRunCondition(Runnable step, BooleanSupplier nextStepRunCondition) - Parameters:
step-nextStepRunCondition-- Returns:
- a new
JobExecutorwith the given step and nextStepRunCondition. - Throws:
RuntimeException- if the given step is null.RuntimeException- if the given nextStepRunCondition is null.
-
forStepAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds
public static JobExecutor forStepAndNextStepRunConditionAndDelayBetweenStepRunsInMilliseconds(Runnable step, BooleanSupplier nextStepRunCondition, int delayBetweenStepRunsInMilliseconds) - Parameters:
step-nextStepRunCondition-delayBetweenStepRunsInMilliseconds-- Returns:
- a new
JobExecutorwith the given step, nextStepRunCondition and delayBetweenStepRunsInMilliseconds. - Throws:
RuntimeException- if the given job is null.RuntimeException- if the given condition is null.RuntimeException- if the given delayBetweenStepRunsInMilliseconds is negative.
-
forJobs
-
forJobs
-
caughtError
public boolean caughtError()- Returns:
- true if the current
JobExecutorhas caught an error, false otherwise.
-
getError
- Returns:
- the error of the current
JobExecutor. - Throws:
ArgumentDoesNotHaveAttributeException- if the currentJobExecutordoes not have an error.
-
getFinishedStepRunCount
public int getFinishedStepRunCount()- Returns:
- the number of finished steps of the current
JobExecutor.
-
hasCondition
public boolean hasCondition()- Returns:
- true if the current
JobExecutorhas a condition, false otherwise.
-
hasMaxRunCount
public boolean hasMaxRunCount()- Returns:
- true if the current
JobExecutorhas a max run count, false otherwise.
-
hasTimeInterval
public boolean hasTimeInterval()- Returns:
- true if the current
JobExecutorhas a time interval, false otherwise.
-
isFinished
public boolean isFinished()- Returns:
- true if the current
JobExecutoris finished, false otherwise.
-
isFinishedSuccessfully
public boolean isFinishedSuccessfully()- Returns:
- true if the current
JobExecutoris finished successfully, false otherwise.
-
isRunning
public boolean isRunning()- Returns:
- true if the current
JobExecutoris running, false otherwise.
-
run
public void run()Lets the currentJobExecutorrun.
-