Interface VariableValueParameters.DynamicChoicesBuilder<T>
-
- All Superinterfaces:
AbstractBuilder<ValueParameter<T>>
,Buildable.Builder<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 aValueParameter
that tries to match an argument against a dynamic set of choices and returns an appropriate object based on the supplied argument.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ValueParameter<T>
build()
Tests for validity and creates thisValueParameter
.VariableValueParameters.DynamicChoicesBuilder<T>
choices(java.util.function.Supplier<? extends java.util.Collection<java.lang.String>> choices)
Sets the parameter to get its choices from the suppliedCollection
.VariableValueParameters.DynamicChoicesBuilder<T>
choicesAndResults(java.util.function.Supplier<java.util.Map<java.lang.String,? extends T>> choices)
Sets the parameter to get its choices from the suppliedMap
, where each choice is associated with its own object.VariableValueParameters.DynamicChoicesBuilder<T>
results(java.util.function.Function<java.lang.String,? extends T> results)
Sets the function which defines what result is returned for a specified choice.VariableValueParameters.DynamicChoicesBuilder<T>
showInUsage(boolean showInUsage)
Sets what should happen if the usage of this parameter is requested.
-
-
-
Method Detail
-
choicesAndResults
VariableValueParameters.DynamicChoicesBuilder<T> choicesAndResults(java.util.function.Supplier<java.util.Map<java.lang.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(java.util.function.Supplier<? extends java.util.Collection<java.lang.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
VariableValueParameters.DynamicChoicesBuilder<T> results(java.util.function.Function<java.lang.String,? extends T> 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
VariableValueParameters.DynamicChoicesBuilder<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 interfaceAbstractBuilder<T>
- Specified by:
build
in interfaceBuildable.Builder<T>
- Returns:
- The
ValueParameter
- Throws:
java.lang.IllegalStateException
- if no choices have been specified
-
-