Interface VariableValueParameters.StaticChoicesBuilder<T>
-
- All Superinterfaces:
Buildable.Builder<ValueParameter<T>>
,Builder<ValueParameter<T>,VariableValueParameters.StaticChoicesBuilder<T>>
,ResettableBuilder<ValueParameter<T>,VariableValueParameters.StaticChoicesBuilder<T>>
- Enclosing class:
- VariableValueParameters
public static interface VariableValueParameters.StaticChoicesBuilder<T> extends Builder<ValueParameter<T>,VariableValueParameters.StaticChoicesBuilder<T>>
A builder that creates aValueParameter
that tries to match an argument against a fixed set of choices and returns an appropriate object based on the supplied argument.Note that the choices from such a parameter cannot be changed once this parameter has been built. Should a set of choices that change during the lifetime of the server be required, use the
VariableValueParameters.DynamicChoicesBuilder
instead.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default VariableValueParameters.StaticChoicesBuilder<T>
addChoice(String choice, T returnedObject)
Adds a choice to the parameter, along with the object that would be returned if the choice is selected.VariableValueParameters.StaticChoicesBuilder<T>
addChoices(Iterable<String> choices, Supplier<? extends T> returnedObjectSupplier)
Adds a collection of choices to the parameter, along with aSupplier
that will return an object if one of the choices is selected.default VariableValueParameters.StaticChoicesBuilder<T>
addChoices(Map<String,? extends T> choices)
Adds a collection of choices to the parameter, along with the objects that would be returned if the associated choice is selected.ValueParameter<T>
build()
Tests for validity and creates thisValueParameter
VariableValueParameters.StaticChoicesBuilder<T>
showInUsage(boolean showInUsage)
Sets what should happen if the usage of this parameter is requested.
-
-
-
Method Detail
-
addChoice
default VariableValueParameters.StaticChoicesBuilder<T> addChoice(String choice, T returnedObject)
Adds a choice to the parameter, along with the object that would be returned if the choice is selected.- Parameters:
choice
- The string to be matchedreturnedObject
- Theto return
- Returns:
- This builder, for chaining
-
addChoices
default VariableValueParameters.StaticChoicesBuilder<T> addChoices(Map<String,? extends T> choices)
Adds a collection of choices to the parameter, along with the objects that would be returned if the associated choice is selected.- Parameters:
choices
- AMap
containing the choices and associated objects.- Returns:
- This builder, for chaining
-
addChoices
VariableValueParameters.StaticChoicesBuilder<T> addChoices(Iterable<String> choices, Supplier<? extends T> returnedObjectSupplier)
Adds a collection of choices to the parameter, along with aSupplier
that will return an object if one of the choices is selected.- Parameters:
choices
- The valid choicesreturnedObjectSupplier
- Supplies the object to return- Returns:
- This builder, for chaining
-
showInUsage
VariableValueParameters.StaticChoicesBuilder<T> showInUsage(boolean 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 interfaceBuildable.Builder<T>
- Returns:
- The
ValueParameter
- Throws:
IllegalStateException
- if no choices have been specified
-
-