Class FutureCommand<T>

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.
  • Constructor Details

    • FutureCommand

      public FutureCommand​(Supplier<CompletableFuture<?>> futureSupplier)
      Initializes a new instance of the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterless operation
    • FutureCommand

      public FutureCommand​(Function<T,​CompletableFuture<?>> futureSupplier)
      Initializes a new instance of the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterized operation
    • FutureCommand

      public FutureCommand​(Supplier<CompletableFuture<?>> futureSupplier, Consumer<Throwable> exceptionHandler)
      Initializes a new instance of the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterless operation
      exceptionHandler - 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 the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterized operation
      exceptionHandler - 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 the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterless operation
      condition - a value that controls the executability of the command
    • FutureCommand

      public FutureCommand​(Function<T,​CompletableFuture<?>> futureSupplier, ObservableValue<Boolean> condition)
      Initializes a new instance of the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterized operation
      condition - 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 the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterless operation
      condition - a value that controls the executability of the command
      exceptionHandler - 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 the FutureCommand class.
      Parameters:
      futureSupplier - supplier that returns a CompletableFuture encapsulating a parameterized operation
      condition - a value that controls the executability of the command
      exceptionHandler - handler for exceptions thrown by the operation; if none is provided, exceptions will be thrown on the calling thread
  • Method Details

    • getCancelCommand

      public Command<Void> getCancelCommand()
      Gets a command that can be used to cancel the currently running operation. Invoking the command calls CompletableFuture.cancel(boolean) on the current operation.
    • execute

      public void execute​(T parameter)
      Description copied from interface: Command
      Executes the command.
      Parameters:
      parameter - the parameter that is passed to the command implementation
    • endExecution

      protected void endExecution()
      Overrides:
      endExecution in class CommandBase<T>