Package page.codeberg.friedolyn.client
Class Client.FetchEmailAddress
java.lang.Object
page.codeberg.friedolyn.util.Task<jakarta.mail.internet.InternetAddress>
page.codeberg.friedolyn.client.FriedolinClient.FetchEmailAddress
page.codeberg.friedolyn.client.Client.FetchEmailAddress
-
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 booleanWhether the task has been prematurelyterminatedby outside intervention.private final @NonNull HashSet<Task.TaskListener<jakarta.mail.internet.InternetAddress>> The subscribers that will be notified about any status changes and progress updates of this task.private jakarta.mail.internet.InternetAddressThe student'suniversity e-mail addressfetched from Friedolin.private BooleanWhether fetching the student's e-mail address was successful. -
Constructor Summary
Constructors -
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.intvoidregisterListener(@NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) Adds a subscriber that is interested in status updates of the action's progress.booleanremoveListener(@NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) 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 e-mail address.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
LISTENERS
@NonNull private final @NonNull HashSet<Task.TaskListener<jakarta.mail.internet.InternetAddress>> LISTENERSThe subscribers that will be notified about any status changes and progress updates of this task. -
success
Whether fetching the student's e-mail address was successful.nulluntil the task has finished. -
result
@Nullable private jakarta.mail.internet.InternetAddress resultThe student'suniversity e-mail addressfetched from Friedolin.nulluntil the fetching process has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminatedby outside intervention.
-
-
Constructor Details
-
FetchEmailAddress
public FetchEmailAddress()
-
-
Method Details
-
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 e-mail address. -
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
-
getTotalWork
public int getTotalWork()- Returns:
- The total number of individual steps to complete this task.
-
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().- Specified by:
runin interfaceRunnable- Specified by:
runin classTask<jakarta.mail.internet.InternetAddress>- Throws:
IllegalStateException- If the action had been started before (each task can only be run once).
-
registerListener
public void registerListener(@NonNull @NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) 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<jakarta.mail.internet.InternetAddress>- Parameters:
taskListener- The subscriber that wants to be informed about the progress of the action.- See Also:
-
removeListener
public boolean removeListener(@NonNull @NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) Removes a subscriber that was previously added to receive status updates of the action's progress.- Specified by:
removeListenerin classTask<jakarta.mail.internet.InternetAddress>- Parameters:
taskListener- 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:
-
getResult
- Specified by:
getResultin classTask<jakarta.mail.internet.InternetAddress>- 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.
-