Package page.codeberg.friedolyn.client
Class HeadlessBrowser.FetchEmailAddress
java.lang.Object
page.codeberg.friedolyn.util.Task<jakarta.mail.internet.InternetAddress>
page.codeberg.friedolyn.client.FriedolinClient.FetchEmailAddress
page.codeberg.friedolyn.client.HeadlessBrowser.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 boolean
Whether the task was prematurelyterminated
by outside intervention.private final @NonNull HashSet
<Task.TaskListener<jakarta.mail.internet.InternetAddress>> The subscribers interested in the progress and status updates of this task.private jakarta.mail.internet.InternetAddress
The student's email address fetched from Friedolin.private Boolean
Whether fetching the student's email address was successful.static final @lombok.NonNull int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Prematurely terminates the action.private void
Notifies allsubscribers
that fetching the student's email address has been prematurelyterminated
by outside intervention.private void
failed()
Notifies allsubscribers
that fetching the student's email address has finished unsuccessfully.void
registerListener
(@NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) Adds a subscriber that is interested in status updates of the action's progress.boolean
removeListener
(@NonNull Task.TaskListener<jakarta.mail.internet.InternetAddress> taskListener) 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 fetching the student's email address has begun.private void
Notifies allsubscribers
that fetching the student's email address has succeeded.private void
updateProgress
(int current, int total) Notifies allsubscribers
about the progress of this task.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
TOTAL_WORK
@NonNull public static final @lombok.NonNull int TOTAL_WORK- See Also:
-
LISTENERS
@NonNull private final @NonNull HashSet<Task.TaskListener<jakarta.mail.internet.InternetAddress>> LISTENERSThe subscribers interested in the progress and status updates of this task. -
result
@Nullable private jakarta.mail.internet.InternetAddress resultThe student's email address fetched from Friedolin.null
until the task has succeeded. -
success
Whether fetching the student's email address was successful.null
until the task has finished. -
isCancelled
private boolean isCancelledWhether the task was prematurelyterminated
by outside intervention.
-
-
Constructor Details
-
FetchEmailAddress
public FetchEmailAddress()
-
-
Method Details
-
updateProgress
private void updateProgress(int current, int total) Notifies allsubscribers
about the progress of this task.- Parameters:
current
- The amount of work that has been done so far.total
- The total number of steps required to complete this task.
-
started
private void started()Notifies allsubscribers
that fetching the student's email address has begun. -
succeeded
private void succeeded()Notifies allsubscribers
that fetching the student's email address has succeeded. Does nothing if theresult
isnull
. -
failed
private void failed()Notifies allsubscribers
that fetching the student's email address has finished unsuccessfully. -
cancelled
private void cancelled()Notifies allsubscribers
that fetching the student's email address has been prematurelyterminated
by outside intervention. -
cancel
-
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:
registerListener
in 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:
removeListener
in 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:
true
if the subscriber was removed,false
if it hadn't been registered in the first place.- See Also:
-
run
public void 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()
. -
getResult
- Specified by:
getResult
in 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.
-