Interface PathfindingSearch


public interface PathfindingSearch
Represents a pathfinding operation that can be configured with callbacks for different outcomes. This interface provides methods to handle successful results, failures, and exceptions, as well as the ability to abort the operation.
Since:
5.4.4
  • Method Details

    • ifPresent

      Executes the given callback if the pathfinding operation results in a successful path or a fallback.
      Parameters:
      callback - the callback to execute if the pathfinding operation is successful or results in a fallback
      Returns:
      this PathfindingSearch instance for method chaining
    • orElse

      Executes the given callback if the pathfinding operation results in a failure, abortion, length limitation, or reaching maximum iterations.
      Parameters:
      callback - the callback to execute if the pathfinding operation fails, is aborted, reaches length limitation, or maximum iterations
      Returns:
      this PathfindingSearch instance for method chaining
    • exceptionally

      PathfindingSearch exceptionally(Consumer<Throwable> callback)
      Executes the given callback if the pathfinding operation results in an exception.
      Parameters:
      callback - the callback to execute if the pathfinding operation results in an exception
      Returns:
      this PathfindingSearch instance for method chaining
    • resultBlocking

      PathfinderResult resultBlocking()
      Blocks until the pathfinding operation completes and returns the result.

      This method waits for the pathfinding process to finish and retrieves the final outcome, encapsulated as a PathfinderResult. It ensures that the calling thread is blocked until the result is ready, making it suitable for scenarios where synchronous behavior is required.

      Returns:
      the PathfinderResult representing the outcome of the pathfinding operation, including success, failure, or fallback states, along with the generated path.
      Since:
      5.4.6
    • result

      Retrieves the result of the pathfinding operation if it has completed.

      This method returns an Optional, which may contain the PathfinderResult if the pathfinding process has finished. The result encapsulates the outcome of the operation, which could be successful, failed, or a fallback, along with the potential generated path. If the pathfinding has not completed or there is no result available, an empty Optional is returned.

      Returns:
      an Optional containing the PathfinderResult if the pathfinding operation has completed, or an empty Optional if the result is not yet available or the operation did not complete.
      Since:
      5.4.6
    • done

      boolean done()
      Checks if the pathfinding operation has completed.

      This method returns a boolean indicating whether the pathfinding process has finished. Completion could mean success, failure, or the operation being aborted. It allows determining if the operation's result can be retrieved or further actions should be performed based on its state.

      Returns:
      true if the pathfinding operation is complete; false otherwise.
      Since:
      5.4.6
    • abort

      void abort()
      Aborts the pathfinding operation if it is still in progress.

      This method uses cooperative cancellation. Instead of abruptly terminating the execution thread, it signals the pathfinder to gracefully stop at the next available opportunity (usually the start of the next iteration). This ensures that internal resources are released and cleanup logic is executed correctly.