Module is.codion.swing.common.model
Interface ProgressWorker.Builder<T,V>
- Type Parameters:
T- the worker result typeV- the intermediate result type
- Enclosing class:
ProgressWorker<T,V>
public static sealed interface ProgressWorker.Builder<T,V>
Builds a ProgressWorker instance.
Each handler method can be called multiple times to add multiple handlers.
All handlers are called in the order they were added. When using a task that implements
a handler interface (e.g. ProgressWorker.TaskHandler), those handler methods are added first,
and any handlers added via this builder are called after.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()execute()Builds and executes a newProgressWorkerbased on this buildermaximum(int maximum) Overrides any maximum progress specified by the task itself.onCancelled(Runnable onCancelled) Adds a handler called on the Event Dispatch Thread if the background task is cancelled viaSwingWorker.cancel(boolean)or if it throws aCancelException.Adds a handler called on the Event Dispatch Thread when the task is done running, successfully or not, before the result is processed.onException(Consumer<Exception> onException) Adds a handler called on the Event Dispatch Thread if an exception occurred.onInterrupted(Runnable onInterrupted) Adds a handler called on the Event Dispatch Thread if the background task was interrupted.onProgress(Consumer<Integer> onProgress) Adds a handler called on the Event Dispatch Thread when progress is reported.Adds a handler called on the Event Dispatch Thread when chunks are available for publishing.Adds a handler called on the Event Dispatch Thread when the result of a successful run is available, after anyonSuccess(Runnable)handlers.Adds a handler called on the EDT before background processing is started.Adds a handler called on the Event Dispatch Thread after a successful task run, before anyonResult(Consumer)handlers.
-
Method Details
-
maximum
Overrides any maximum progress specified by the task itself.- Parameters:
maximum- the maximum progress,ProgressWorker.DEFAULT_MAXIMUM(100) by default- Returns:
- this builder instance
- See Also:
-
onStarted
Adds a handler called on the EDT before background processing is started.- Parameters:
onStarted- the handler to add- Returns:
- this builder instance
-
onDone
Adds a handler called on the Event Dispatch Thread when the task is done running, successfully or not, before the result is processed.- Parameters:
onDone- the handler to add- Returns:
- this builder instance
-
onSuccess
Adds a handler called on the Event Dispatch Thread after a successful task run, before anyonResult(Consumer)handlers.- Parameters:
onSuccess- the handler to add- Returns:
- this builder instance
-
onResult
Adds a handler called on the Event Dispatch Thread when the result of a successful run is available, after anyonSuccess(Runnable)handlers.- Parameters:
onResult- the handler to add- Returns:
- this builder instance
-
onProgress
Adds a handler called on the Event Dispatch Thread when progress is reported.- Parameters:
onProgress- the handler to add- Returns:
- this builder instance
-
onPublish
Adds a handler called on the Event Dispatch Thread when chunks are available for publishing.- Parameters:
onPublish- the handler to add- Returns:
- this builder instance
-
onException
Adds a handler called on the Event Dispatch Thread if an exception occurred.- Parameters:
onException- the handler to add- Returns:
- this builder instance
-
onCancelled
Adds a handler called on the Event Dispatch Thread if the background task is cancelled viaSwingWorker.cancel(boolean)or if it throws aCancelException.- Parameters:
onCancelled- the handler to add- Returns:
- this builder instance
-
onInterrupted
Adds a handler called on the Event Dispatch Thread if the background task was interrupted.- Parameters:
onInterrupted- the handler to add- Returns:
- this builder instance
-
execute
ProgressWorker<T,V> execute()Builds and executes a newProgressWorkerbased on this builder- Returns:
- a
ProgressWorkerbased on this builder
-
build
ProgressWorker<T,V> build()- Returns:
- a
ProgressWorkerbased on this builder
-