Interface PathfindingSearch
- Since:
- 5.4.4
-
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts the pathfinding operation if it is still in progress.booleandone()Checks if the pathfinding operation has completed.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.result()Retrieves the result of the pathfinding operation if it has completed.Blocks until the pathfinding operation completes and returns the result.
-
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
-
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
PathfinderResultrepresenting the outcome of the pathfinding operation, including success, failure, or fallback states, along with the generated path. - Since:
- 5.4.6
-
result
Optional<PathfinderResult> result()Retrieves the result of the pathfinding operation if it has completed.This method returns an
Optional, which may contain thePathfinderResultif 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 emptyOptionalis returned.- Returns:
- an
Optionalcontaining thePathfinderResultif the pathfinding operation has completed, or an emptyOptionalif 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.
-