Package page.codeberg.friedolyn.client
Class Client.FetchPersonalData
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The possible kinds of personal data that can be fetched from Friedolin.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 TypeFieldDescriptionstatic final int
The expected number of individial steps to complete this task, assuming that we're already logged in.private boolean
Whether the task has been prematurelyterminated
by outside intervention.private final @NonNull Client.FetchPersonalData.Kind
What personal data to retrieve from Friedolin.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
The personal data fetched from Friedolin.private Boolean
Whether the task has been executed successfully. -
Constructor Summary
ConstructorsConstructorDescriptionFetchPersonalData
(@NonNull Client.FetchPersonalData.Kind kind) Creates a new task to fetch the student's personal data from Friedolin. -
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 personal data.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
DEFAULT_TOTAL_WORK
public static final int DEFAULT_TOTAL_WORKThe expected number of individial steps to complete this task, assuming that we're already logged in.- See Also:
-
KIND
What personal data to retrieve from Friedolin. -
LISTENERS
The subscribers that will be notified about any status changes and progress updates of this task. -
result
The personal data fetched from Friedolin.null
until the task has finished. -
success
Whether the task has been executed successfully.null
until the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminated
by outside intervention.
-
-
Constructor Details
-
FetchPersonalData
FetchPersonalData(@NonNull @NonNull Client.FetchPersonalData.Kind kind) Creates a new task to fetch the student's personal data from Friedolin.- Parameters:
kind
- What personal data to retrieve from Friedolin.
-
-
Method Details
-
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:
-
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 personal data. -
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
. -
cancelled
private void cancelled()Notifies allsubscribers
that the fetching process was terminated prematurely by outside intervention. -
cancel
-
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()
.
-