Interface VariableValueParameters.DynamicChoicesBuilder<T>
- All Superinterfaces:
AbstractBuilder<ValueParameter<T>>
,Builder<ValueParameter<T>,
,VariableValueParameters.DynamicChoicesBuilder<T>> ResettableBuilder<ValueParameter<T>,
VariableValueParameters.DynamicChoicesBuilder<T>>
- Enclosing class:
- VariableValueParameters
public static interface VariableValueParameters.DynamicChoicesBuilder<T>
extends Builder<ValueParameter<T>,VariableValueParameters.DynamicChoicesBuilder<T>>
A builder that creates a
ValueParameter
that tries to match an
argument against a dynamic set of choices and returns an appropriate object
based on the supplied argument.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Tests for validity and creates thisValueParameter
.choices
(Supplier<? extends Collection<String>> choices) Sets the parameter to get its choices from the suppliedCollection
.choicesAndResults
(Supplier<Map<String, ? extends T>> choices) Sets the parameter to get its choices from the suppliedMap
, where each choice is associated with its own object.Sets the function which defines what result is returned for a specified choice.showInUsage
(boolean showInUsage) Sets what should happen if the usage of this parameter is requested.
-
Method Details
-
choicesAndResults
VariableValueParameters.DynamicChoicesBuilder<T> choicesAndResults(Supplier<Map<String, ? extends T>> choices) Sets the parameter to get its choices from the suppliedMap
, where each choice is associated with its own object.- Parameters:
choices
- A supplier that returns an appropriate map.- Returns:
- This builder, for chaining
-
choices
VariableValueParameters.DynamicChoicesBuilder<T> choices(Supplier<? extends Collection<String>> choices) Sets the parameter to get its choices from the suppliedCollection
.- Parameters:
choices
- A supplier that returns the appropriate choices.- Returns:
- This builder, for chaining
-
results
Sets the function which defines what result is returned for a specified choice.- Parameters:
results
- A function that returns the appropriate object for the provided choice- Returns:
- This builder, for chaining
-
showInUsage
Sets what should happen if the usage of this parameter is requested.If there are 5 or fewer choices available, and "showInUsage" is true, the choices will be shown in the command usage. Otherwise, the usage will only display only the key.
- Parameters:
showInUsage
- true if the choices should be shown- Returns:
- This builder, for chaining
-
build
ValueParameter<T> build()Tests for validity and creates thisValueParameter
.- Specified by:
build
in interfaceAbstractBuilder<T>
- Returns:
- The
ValueParameter
- Throws:
IllegalStateException
- if no choices have been specified
-