Skip to content

Commit

Permalink
add AsyncSuggestionProvider#from(SuggestionProvider)
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Sep 19, 2024
1 parent 8ddd05e commit a206f07
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ public interface AsyncSuggestionProvider<A extends CommandActor> extends BaseSug
@NotNull
CompletableFuture<Collection<String>> getSuggestionsAsync(@NotNull ExecutionContext<A> context);

/**
* Creates a {@link AsyncSuggestionProvider} from the given {@link SuggestionProvider}
*
* @param provider Provider to wrap
* @param <A> The actor type
* @return The {@link AsyncSuggestionProvider}
*/
static <A extends CommandActor> @NotNull AsyncSuggestionProvider<A> from(@NotNull SuggestionProvider<A> provider) {
return context -> CompletableFuture.supplyAsync(() -> provider.getSuggestions(context));
}

}

0 comments on commit a206f07

Please sign in to comment.