java.lang.Object
javafx.scene.input.CommandBase<T>
javafx.scene.input.FutureCommand<T>
- All Implemented Interfaces:
Command<T>
public class FutureCommand<T> extends CommandBase<T>
A command implementation that uses
CompletableFuture to encapsulate its operation.-
Property Summary
Properties inherited from class javafx.scene.input.CommandBase
executable, executing -
Constructor Summary
Constructors Constructor Description FutureCommand(Function<T,CompletableFuture<?>> futureSupplier)Initializes a new instance of theFutureCommandclass.FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, ObservableValue<Boolean> condition)Initializes a new instance of theFutureCommandclass.FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, ObservableValue<Boolean> condition, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.FutureCommand(Supplier<CompletableFuture<?>> futureSupplier)Initializes a new instance of theFutureCommandclass.FutureCommand(Supplier<CompletableFuture<?>> futureSupplier, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.FutureCommand(Supplier<CompletableFuture<Void>> futureSupplier, ObservableValue<Boolean> condition)Initializes a new instance of theFutureCommandclass.FutureCommand(Supplier<CompletableFuture<Void>> futureSupplier, ObservableValue<Boolean> condition, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass. -
Method Summary
Modifier and Type Method Description protected voidendExecution()voidexecute(T parameter)Executes the command.Command<Void>getCancelCommand()Gets a command that can be used to cancel the currently running operation.Methods inherited from class javafx.scene.input.CommandBase
executableProperty, executingProperty, startExecutionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javafx.scene.input.Command
isExecutable, isExecuting
-
Constructor Details
-
FutureCommand
Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterless operation
-
FutureCommand
Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterized operation
-
FutureCommand
public FutureCommand(Supplier<CompletableFuture<?>> futureSupplier, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterless operationexceptionHandler- handler for exceptions thrown by the operation; if none is provided, exceptions will be thrown on the calling thread
-
FutureCommand
public FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterized operationexceptionHandler- handler for exceptions thrown by the operation; if none is provided, exceptions will be thrown on the calling thread
-
FutureCommand
public FutureCommand(Supplier<CompletableFuture<Void>> futureSupplier, ObservableValue<Boolean> condition)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterless operationcondition- a value that controls the executability of the command
-
FutureCommand
public FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, ObservableValue<Boolean> condition)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterized operationcondition- a value that controls the executability of the command
-
FutureCommand
public FutureCommand(Supplier<CompletableFuture<Void>> futureSupplier, ObservableValue<Boolean> condition, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterless operationcondition- a value that controls the executability of the commandexceptionHandler- handler for exceptions thrown by the operation; if none is provided, exceptions will be thrown on the calling thread
-
FutureCommand
public FutureCommand(Function<T,CompletableFuture<?>> futureSupplier, ObservableValue<Boolean> condition, Consumer<Throwable> exceptionHandler)Initializes a new instance of theFutureCommandclass.- Parameters:
futureSupplier- supplier that returns aCompletableFutureencapsulating a parameterized operationcondition- a value that controls the executability of the commandexceptionHandler- handler for exceptions thrown by the operation; if none is provided, exceptions will be thrown on the calling thread
-
-
Method Details
-
getCancelCommand
Gets a command that can be used to cancel the currently running operation. Invoking the command callsCompletableFuture.cancel(boolean)on the current operation. -
execute
Description copied from interface:CommandExecutes the command.- Parameters:
parameter- the parameter that is passed to the command implementation
-
endExecution
protected void endExecution()- Overrides:
endExecutionin classCommandBase<T>
-