Package page.codeberg.friedolyn.client
Class Client.FetchClearname
java.lang.Object
page.codeberg.friedolyn.util.Task<String>
page.codeberg.friedolyn.client.FriedolinClient.FetchClearname
page.codeberg.friedolyn.client.Client.FetchClearname
-
Nested Class Summary
Nested classes/interfaces inherited from class page.codeberg.friedolyn.util.Task
Task.CancelListener, Task.FailureListener<ResultType>, Task.ProgressListener, Task.SuccessListener<ResultType>, Task.TaskListener<ResultType>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Whether the task has been prematurelyterminated
by outside intervention.private final @NonNull HashSet
<Task.TaskListener<String>> The subscribers that will be notified about any status changes and progress updates of this task.private String
Thestudent's clear name
fetched from Friedolin.private Boolean
Whether fetching the student's clear name was successful. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Prematurely terminates the action.private void
Notifies allsubscribers
that the fetching process was terminated prematurely by outside intervention.private void
failed()
Notifies allsubscribers
that the fetching process finished unsuccessfully.void
registerListener
(@NonNull Task.TaskListener<String> listener) Adds a subscriber that is interested in status updates of the action's progress.boolean
removeListener
(@NonNull Task.TaskListener<String> listener) Removes a subscriber that was previously added to receive status updates of the action's progress.void
run()
Begins the execution of the action.private void
started()
Notifies allsubscribers
that the fetching process has begun.private void
Notifies allsubscribers
that the fetching process finished successfully.private void
updateProgress
(int current, int total) Notifies allsubscribers
about the amount of work that has already been done and the total amount of work that needs to be done to finish fetching the student's clear name.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
result
Thestudent's clear name
fetched from Friedolin.null
until the task has finished. -
success
Whether fetching the student's clear name was successful.null
until the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminated
by outside intervention. -
LISTENERS
The subscribers that will be notified about any status changes and progress updates of this task.
-
-
Constructor Details
-
FetchClearname
public FetchClearname()
-
-
Method Details
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribers
about the amount of work that has already been done and the total amount of work that needs to be done to finish fetching the student's clear name. -
started
private void started()Notifies allsubscribers
that the fetching process has begun. -
failed
private void failed()Notifies allsubscribers
that the fetching process finished unsuccessfully. -
succeeded
private void succeeded()Notifies allsubscribers
that the fetching process finished successfully. Does nothing ifresult
isnull
. -
registerListener
Adds a subscriber that is interested in status updates of the action's progress. Does NOT remove or replace any existing listeners.- Specified by:
registerListener
in classTask<String>
- Parameters:
listener
- The subscriber that wants to be informed about the progress of the action.- See Also:
-
removeListener
Removes a subscriber that was previously added to receive status updates of the action's progress.- Specified by:
removeListener
in classTask<String>
- Parameters:
listener
- The subscriber that no longer wants to be informed about the progress of the action. Must be the exact same reference that was previously registered.- Returns:
true
if the subscriber was removed,false
if it hadn't been registered in the first place.- See Also:
-
cancel
-
cancelled
private void cancelled()Notifies allsubscribers
that the fetching process was terminated prematurely by outside intervention. -
getResult
- Specified by:
getResult
in classTask<String>
- Returns:
- The end product generated by the action. Empty if the action has not finished yet.
The presence of
Result.getResult()
does NOT indicate success. OnlyResult.getSuccess()
can be used to determine success or failure.
-
run
Begins the execution of the action. The action will run in the same thread that it was envoked from. UseTask.cancel()
to prematurely terminate the action. The end product of the action can be retrieved usingTask.getResult()
.
-