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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the pathfinding operation if it is still in progress.exceptionally(Consumer<Throwable> callback) Executes the given callback if the pathfinding operation results in an exception.ifPresent(Consumer<PathfinderResult> callback) Executes the given callback if the pathfinding operation results in a successful path or a fallback.orElse(Consumer<PathfinderResult> callback) Executes the given callback if the pathfinding operation results in a failure, abortion, length limitation, or reaching maximum iterations.
-
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
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
-
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.
-