Package page.codeberg.friedolyn.client
Class Client.FetchPersonalData
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe 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 intThe expected number of individial steps to complete this task, assuming that we're already logged in.private booleanWhether the task has been prematurelyterminatedby outside intervention.private final @NonNull Client.FetchPersonalData.KindWhat 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 StringThe personal data fetched from Friedolin.private BooleanWhether 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 TypeMethodDescriptionvoidcancel()Prematurely terminates the action.private voidNotifies allsubscribersthat the fetching process was terminated prematurely by outside intervention.private voidfailed()Notifies allsubscribersthat the fetching process finished unsuccessfully.voidregisterListener(@NonNull Task.TaskListener<String> listener) Adds a subscriber that is interested in status updates of the action's progress.booleanremoveListener(@NonNull Task.TaskListener<String> listener) Removes a subscriber that was previously added to receive status updates of the action's progress.voidrun()Begins the execution of the action.private voidstarted()Notifies allsubscribersthat the fetching process has begun.private voidNotifies allsubscribersthat the fetching process finished successfully.private voidupdateProgress(int current, int total) Notifies allsubscribersabout 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.nulluntil the task has finished. -
success
Whether the task has been executed successfully.nulluntil the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminatedby 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:
registerListenerin 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:
removeListenerin 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:
trueif the subscriber was removed,falseif it hadn't been registered in the first place.- See Also:
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribersabout 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 allsubscribersthat the fetching process has begun. -
failed
private void failed()Notifies allsubscribersthat the fetching process finished unsuccessfully. -
succeeded
private void succeeded()Notifies allsubscribersthat the fetching process finished successfully. Does nothing ifresultisnull. -
cancelled
private void cancelled()Notifies allsubscribersthat the fetching process was terminated prematurely by outside intervention. -
cancel
-
getResult
- Specified by:
getResultin 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().
-