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 booleanWhether the task has been prematurelyterminatedby 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.KeePassEntryThe student's Friedolin login credentials.private BooleanWhether the task has been executed successfully. -
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.@NonNull Optional<Result<KeePassXC.KeePassEntry>> voidregisterListener(@NonNull Task.TaskListener<KeePassXC.KeePassEntry> taskListener) Adds a subscriber that is interested in status updates of the action's progress.booleanremoveListener(@NonNull Task.TaskListener<KeePassXC.KeePassEntry> 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 voidNotifies allsubscribersthat 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.nulluntil the task has finished. -
result
The student's Friedolin login credentials.nulluntil the task has finished. -
isCancelled
private boolean isCancelledWhether the task has been prematurelyterminatedby 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:
registerListenerin 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:
removeListenerin 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:
trueif the subscriber was removed,falseif it hadn't been registered in the first place.- See Also:
-
succeeded
private void succeeded()Notifies allsubscribersthat the fetching process finished successfully. Does nothing ifresultisnull. -
failed
private void failed()Notifies allsubscribersthat the fetching process finished unsuccessfully. -
cancelled
private void cancelled()Notifies allsubscribersthat 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:
runin interfaceRunnable- Specified by:
runin 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:
cancelin classTask<KeePassXC.KeePassEntry>- Throws:
IllegalStateException- If the action had not been started before or if it has already finished.
-
getResult
- Specified by:
getResultin 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.
-