Interface VariableValueParameters.StaticChoicesBuilder<T>
- All Superinterfaces:
AbstractBuilder<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 a
ValueParameter
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
Modifier and TypeMethodDescriptionAdds a choice to the parameter, along with the object that would be returned if the choice is selected.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.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.build()
Tests for validity and creates thisValueParameter
showInUsage
(boolean showInUsage) Sets what should happen if the usage of this parameter is requested.
-
Method Details
-
addChoice
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
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
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
-