Interface DefaultValue<C,T>

Type Parameters:
C - command sender type
T - type of the owning argument
All Known Implementing Classes:
DefaultValue.ConstantDefaultValue, DefaultValue.DynamicDefaultValue, DefaultValue.ParsedDefaultValue
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@API(status=STABLE) @FunctionalInterface public interface DefaultValue<C,T>
Default value used when an optional argument is omitted by the command sender.
  • Method Details

    • constant

      static <C, T> @NonNull DefaultValue<C,T> constant(@NonNull T value)
      Returns a constant default value. The argument parser will be bypassed when using a constant default value.
      Type Parameters:
      C - the command sender type
      T - the argument type
      Parameters:
      value - the default value
      Returns:
      the default value instance
    • dynamic

      static <C, T> @NonNull DefaultValue<C,T> dynamic(@NonNull DefaultValue.DefaultValueProvider<C,T> expression)
      Returns a default value that will be evaluated when the command is evaluated. The argument parser will be bypassed when using a dynamic default value.
      Type Parameters:
      C - the command sender type
      T - the argument type
      Parameters:
      expression - the expression producing the default value
      Returns:
      the default value instance
    • failableDynamic

      static <C, T> @NonNull DefaultValue<C,T> failableDynamic(@NonNull DefaultValue<C,T> expression)
      Returns a default value that will be evaluated when the command is evaluated. The argument parser will be bypassed when using a dynamic default value.
      Type Parameters:
      C - the command sender type
      T - the argument type
      Parameters:
      expression - the expression producing the default value
      Returns:
      the default value instance
    • parsed

      static <C, T> @NonNull DefaultValue<C,T> parsed(@NonNull String value)
      Returns a default value that will be parsed together with the command.
      Type Parameters:
      C - the command sender type
      T - the argument type
      Parameters:
      value - value that gets parsed by the argument parser when the command is being evaluated
      Returns:
      the default value instance
    • evaluateDefault

      @NonNull ArgumentParseResult<T> evaluateDefault(@NonNull CommandContext<C> context)
      Evaluates the default value for the given context.
      Parameters:
      context - the context
      Returns:
      the default value