Interface Flag.Builder

All Superinterfaces:
AbstractBuilder<Flag>, Builder<Flag,Flag.Builder>, ResettableBuilder<Flag,Flag.Builder>
Enclosing interface:
Flag

public static interface Flag.Builder extends Builder<Flag,Flag.Builder>
A builder for creating Flags.
  • Method Details

    • alias

      Flag.Builder alias(String alias)
      Specifies an alias for this flag. The alias must not start with a dash, this will be handled by the builder.

      If the alias is a single character, a single dash will be prefixed to the alias (e.g. an alias of a will become -a upon invocation. Otherwise, two dashes will be prefixed to the alias (e.g. all will become --all.

      Parameters:
      alias - The alias that this flag will have
      Returns:
      This builder, for chaining
    • aliases

      default Flag.Builder aliases(String... aliases)
      Specify multiple aliases at once for this flag.

      The requirements for each alias are described in alias(String)

      Parameters:
      aliases - The aliases to add
      Returns:
      This builder, for chaining
    • aliases

      Flag.Builder aliases(Iterable<String> aliases)
      Specify multiple aliases at once for this flag.

      The requirements for each alias are described in alias(String)

      Parameters:
      aliases - The aliases to add
      Returns:
      This builder, for chaining
    • setPermission

      Flag.Builder setPermission(@Nullable String permission)
      Specifies the permission required to use this flag. A null permission indicates that anyone will be able to use the flag.

      This will overwrite anything provided in setRequirement(Predicate)

      Parameters:
      permission - The permission to check for
      Returns:
      This builder, for chaining
    • setRequirement

      Flag.Builder setRequirement(@Nullable Predicate<CommandCause> requirement)
      Specifies the requirement to use this flag. A null requirement indicates that anyone will be able to use the flag.

      This will overwrite anything provided in setPermission(String)

      Parameters:
      requirement - A Predicate that checks whether a CommandCause meets the requirement for invocation.
      Returns:
      This builder, for chaining
    • setParameter

      Flag.Builder setParameter(@Nullable Parameter parameter)
      Sets a Parameter that may be executed after the flag.

      This will allow you to set a parameter that is conditional on this flag being specified. It is always required directly after the flag, separated by a space. Thus, setting this on a flag will result in the usage of form:

      --flag <parameter>

      The Parameter may be optional and may have its own requirements like any standard parameter. It is important to note, however, that as a flag may be invoked more than once, a CommandContext may also have more than one entry under the given Parameter.Key.

      Parameters:
      parameter - The parameter to parse after this flag
      Returns:
      This builder, for chaining
    • build

      Flag build() throws IllegalStateException
      Validates this builder and builds this Flag.
      Specified by:
      build in interface AbstractBuilder<Flag>
      Returns:
      A Flag
      Throws:
      IllegalStateException - if no key or no alias is specified