Package org.incendo.cloud.suggestion
Interface SuggestionProvider<C>
- Type Parameters:
C- command sender type
- All Known Subinterfaces:
BlockingSuggestionProvider<C>,BlockingSuggestionProvider.Strings<C>
- All Known Implementing Classes:
BooleanParser,ByteParser,CommandFlagParser,DurationParser,EitherParser,EnumParser,IntegerParser,LiteralParser,LongParser,ShortParser
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Provider of suggestions
-
Method Summary
Modifier and TypeMethodDescriptionstatic <C> @NonNull SuggestionProvider<C> blocking(@NonNull BlockingSuggestionProvider<C> blockingSuggestionProvider) Utility method to simplify implementingBlockingSuggestionProviderusing a lambda, for methods that accept aSuggestionProvider.static <C> @NonNull SuggestionProvider<C> blockingStrings(@NonNull BlockingSuggestionProvider.Strings<C> blockingStringsSuggestionProvider) Utility method to simplify implementingBlockingSuggestionProvider.Stringsusing a lambda, for methods that accept aSuggestionProvider.static <C> @NonNull SuggestionProvider<C> Get a suggestion provider that provides no suggestions.static <C> @NonNull SuggestionProvider<C> suggesting(@NonNull Iterable<? extends @NonNull Suggestion> suggestions) Create aSuggestionProviderthat provides constant suggestions.static <C> @NonNull SuggestionProvider<C> suggesting(@NonNull Suggestion @NonNull ... suggestions) Create aSuggestionProviderthat provides constant suggestions.static <C> @NonNull SuggestionProvider<C> suggestingStrings(@NonNull Iterable<@NonNull String> suggestions) Create aSuggestionProviderthat provides constant string suggestions.static <C> @NonNull SuggestionProvider<C> suggestingStrings(@NonNull String @NonNull ... suggestions) Create aSuggestionProviderthat provides constant string suggestions.@NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<C> context, @NonNull CommandInput input) Returns a future that completes with the suggestions for the giveninput.
-
Method Details
-
suggestionsFuture
@NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<C> context, @NonNull CommandInput input) Returns a future that completes with the suggestions for the giveninput.The
inputparameter contains all sender-provided input that has not yet been consumed by the argument parsers. If the component that the suggestion provider is generating suggestions for consumes multiple tokens the suggestion provider might receive aCommandInputinstance containing multiple tokens.CommandInput.lastRemainingToken()may be used to extract the part of the command that is currently being completed by the command sender.If you don't need to return a future, you can implement
BlockingSuggestionProviderinstead.- Parameters:
context- the context of the suggestion lookupinput- the current input- Returns:
- the suggestions
-
noSuggestions
Get a suggestion provider that provides no suggestions.- Type Parameters:
C- command sender type- Returns:
- suggestion provider
-
blocking
static <C> @NonNull SuggestionProvider<C> blocking(@NonNull BlockingSuggestionProvider<C> blockingSuggestionProvider) Utility method to simplify implementingBlockingSuggestionProviderusing a lambda, for methods that accept aSuggestionProvider.- Type Parameters:
C- command sender type- Parameters:
blockingSuggestionProvider- suggestion provider- Returns:
- suggestion provider
-
blockingStrings
static <C> @NonNull SuggestionProvider<C> blockingStrings(@NonNull BlockingSuggestionProvider.Strings<C> blockingStringsSuggestionProvider) Utility method to simplify implementingBlockingSuggestionProvider.Stringsusing a lambda, for methods that accept aSuggestionProvider.- Type Parameters:
C- command sender type- Parameters:
blockingStringsSuggestionProvider- suggestion provider- Returns:
- suggestion provider
-
suggesting
Create aSuggestionProviderthat provides constant suggestions.- Type Parameters:
C- command sender type- Parameters:
suggestions- list of strings to suggest- Returns:
- suggestion provider
-
suggestingStrings
static <C> @NonNull SuggestionProvider<C> suggestingStrings(@NonNull String @NonNull ... suggestions) Create aSuggestionProviderthat provides constant string suggestions.- Type Parameters:
C- command sender type- Parameters:
suggestions- list of strings to suggest- Returns:
- suggestion provider
-
suggesting
static <C> @NonNull SuggestionProvider<C> suggesting(@NonNull Iterable<? extends @NonNull Suggestion> suggestions) Create aSuggestionProviderthat provides constant suggestions.- Type Parameters:
C- command sender type- Parameters:
suggestions- list of strings to suggest- Returns:
- suggestion provider
-
suggestingStrings
static <C> @NonNull SuggestionProvider<C> suggestingStrings(@NonNull Iterable<@NonNull String> suggestions) Create aSuggestionProviderthat provides constant string suggestions.- Type Parameters:
C- command sender type- Parameters:
suggestions- list of strings to suggest- Returns:
- suggestion provider
-