Package page.codeberg.friedolyn.crypto
Class KeePassXC.AssociateAndLoginTask
java.lang.Object
page.codeberg.friedolyn.util.Task<KeePassXC.KeePassEntry>
page.codeberg.friedolyn.crypto.KeePassXC.AssociateAndLoginTask
- All Implemented Interfaces:
Runnable
- Enclosing class:
KeePassXC
A
Task
that does KeePassXC.connect()
, KeePassXC.associate()
, and KeePassXC.getFriedolinLogins()
all in one
go.-
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 HashSet
<Task.TaskListener<KeePassXC.KeePassEntry>> The subscribers that will be notified about any status changes and progress updates of this task.private KeePassXC.KeePassEntry
The student's Friedolin login credentials.private Boolean
Whether the task has been executed successfully. -
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.@NonNull Optional
<Result<KeePassXC.KeePassEntry>> void
registerListener
(@NonNull Task.TaskListener<KeePassXC.KeePassEntry> taskListener) Adds a subscriber that is interested in status updates of the action's progress.boolean
removeListener
(@NonNull Task.TaskListener<KeePassXC.KeePassEntry> 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
Notifies allsubscribers
that the fetching process finished successfully.Methods inherited from class page.codeberg.friedolyn.util.Task
setOnCancelled, setOnFailed, setOnProgressUpdate, setOnSucceeded
-
Field Details
-
LISTENERS
The subscribers that will be notified about any status changes and progress updates of this task. -
success
Whether the task has been executed successfully.null
until the task has finished. -
result
The student's Friedolin login credentials.null
until the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminated
by outside intervention.
-
-
Constructor Details
-
AssociateAndLoginTask
private AssociateAndLoginTask()
-
-
Method Details
-
registerListener
public void registerListener(@NonNull @NonNull Task.TaskListener<KeePassXC.KeePassEntry> 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<KeePassXC.KeePassEntry>
- 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<KeePassXC.KeePassEntry> taskListener) Removes a subscriber that was previously added to receive status updates of the action's progress.- Specified by:
removeListener
in classTask<KeePassXC.KeePassEntry>
- 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:
-
succeeded
private void succeeded()Notifies allsubscribers
that the fetching process finished successfully. Does nothing ifresult
isnull
. -
failed
private void failed()Notifies allsubscribers
that the fetching process finished unsuccessfully. -
cancelled
private void cancelled()Notifies allsubscribers
that the fetching process was terminated prematurely by outside intervention. -
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()
.- Specified by:
run
in interfaceRunnable
- Specified by:
run
in classTask<KeePassXC.KeePassEntry>
-
cancel
Prematurely terminates the action. The action will be stopped as soon as possible, but it may not be immediate, depending on the implementation.- Specified by:
cancel
in classTask<KeePassXC.KeePassEntry>
- Throws:
IllegalStateException
- If the action had not been started before or if it has already finished.
-
getResult
- Specified by:
getResult
in classTask<KeePassXC.KeePassEntry>
- 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.
-