Skip to content

Commit 76deb51

Browse files
committed
Add SuggestionProvider.of(Supplier<Collection<String>>)
1 parent eda4d8c commit 76deb51

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

common/src/main/java/revxrsal/commands/autocomplete/SuggestionProvider.java

+11
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ static SuggestionProvider of(@Nullable String... suggestions) {
7878
return (args, sender, command) -> values;
7979
}
8080

81+
/**
82+
* Returns a {@link SuggestionProvider} that computes the given supplier
83+
* every time suggestions are returned.
84+
*
85+
* @param supplier The collection supplier
86+
* @return The provider
87+
*/
88+
static SuggestionProvider of(@NotNull Supplier<Collection<String>> supplier) {
89+
return (args, sender, command) -> supplier.get();
90+
}
91+
8192
/**
8293
* Returns a {@link SuggestionProvider} that takes the given collection of
8394
* values and maps it to strings according to the given function.

0 commit comments

Comments
 (0)