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 Details

    • 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 matched
      returnedObject - The to 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 - A Map 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 a Supplier that will return an object if one of the choices is selected.
      Parameters:
      choices - The valid choices
      returnedObjectSupplier - 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 this ValueParameter
      Specified by:
      build in interface AbstractBuilder<T>
      Returns:
      The ValueParameter
      Throws:
      IllegalStateException - if no choices have been specified