Package page.codeberg.friedolyn.util
Class Task.TaskListener<ResultType>
java.lang.Object
page.codeberg.friedolyn.util.Task.TaskListener<ResultType>
- Type Parameters:
ResultType
- The class of the end product that the action executed generates.
- All Implemented Interfaces:
Task.CancelListener
,Task.FailureListener<ResultType>
,Task.ProgressListener
,Task.SuccessListener<ResultType>
- Enclosing class:
Task<ResultType>
public abstract static class Task.TaskListener<ResultType>
extends Object
implements Task.ProgressListener, Task.SuccessListener<ResultType>, Task.FailureListener<ResultType>, Task.CancelListener
A subscriber that is interested in status updates of the action's progress.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <ResultType>
@NonNull Task.TaskListener<ResultType> from
(@NonNull Task.CancelListener cancelListener) Converts aTask.CancelListener
to aTask.TaskListener
.static <ResultType>
@NonNull Task.TaskListener<ResultType> from
(@NonNull Task.FailureListener<ResultType> failureListener) Converts aTask.FailureListener
to aTask.TaskListener
.static <ResultType>
@NonNull Task.TaskListener<ResultType> from
(@NonNull Task.ProgressListener progressListener) Converts aTask.ProgressListener
to aTask.TaskListener
.static <ResultType>
@NonNull Task.TaskListener<ResultType> from
(@NonNull Task.SuccessListener<ResultType> successListener) Converts aTask.SuccessListener
to aTask.TaskListener
.abstract void
Called when execution of the action has begun.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface page.codeberg.friedolyn.util.Task.CancelListener
onCancelled
Methods inherited from interface page.codeberg.friedolyn.util.Task.FailureListener
onFailed
Methods inherited from interface page.codeberg.friedolyn.util.Task.ProgressListener
onProgressUpdate
Methods inherited from interface page.codeberg.friedolyn.util.Task.SuccessListener
onSucceeded
-
Constructor Details
-
TaskListener
public TaskListener()
-
-
Method Details
-
onStarted
public abstract void onStarted()Called when execution of the action has begun. -
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.ProgressListener progressListener) Converts aTask.ProgressListener
to aTask.TaskListener
. Useful if only progress updates are needed and no other information.- Type Parameters:
ResultType
- The class of the result that the action executed produces.- Parameters:
progressListener
- What to do when progress has been made executing the task. Will be called byTask.ProgressListener.onProgressUpdate(int, int)
.- Returns:
- A
Task.TaskListener
that calls the givenTask.ProgressListener
when progress is made. - See Also:
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.SuccessListener<ResultType> successListener) Converts aTask.SuccessListener
to aTask.TaskListener
. Useful if only the result is needed and no other information.- Type Parameters:
ResultType
- The class of the result that the action executed produces.- Parameters:
successListener
- What to do when the action has succeeded. Will be called byTask.SuccessListener.onSucceeded(Object)
.- Returns:
- A
Task.TaskListener
that calls the givenTask.SuccessListener
when the action has succeeded.
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.FailureListener<ResultType> failureListener) Converts aTask.FailureListener
to aTask.TaskListener
. Useful if only the result is needed and no other information.- Type Parameters:
ResultType
- The class of the result that the action executed produces.- Parameters:
failureListener
- What to do when the action has failed. Will be called byTask.FailureListener.onFailed(Optional)
.- Returns:
- A
Task.TaskListener
that calls the givenTask.FailureListener
when the action has failed.
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.CancelListener cancelListener) Converts aTask.CancelListener
to aTask.TaskListener
. Useful if only the result is needed and no other information.- Type Parameters:
ResultType
- The class of the result that the action executed produces.- Parameters:
cancelListener
- What to do when the action has been cancelled. Will be called byTask.CancelListener.onCancelled()
.- Returns:
- A
Task.TaskListener
that calls the givenTask.CancelListener
when the action has been cancelled.
-