Interface ParameterType<S extends Source,T>

Type Parameters:
S - The type of the command source.
T - The type of the parameter value.
All Known Implementing Classes:
BaseParameterType, ConstrainedParameterTypeDecorator, ParameterArray, ParameterBoolean, ParameterCollection, ParameterCommand, ParameterCompletableFuture, ParameterEnum, ParameterFlag, ParameterMap, ParameterNumber, ParameterOptional, ParameterString, ParameterUUID

public interface ParameterType<S extends Source,T>
Represents a type handler for command parameters, providing methods for type resolution, input matching, and suggestions.
  • Method Details

    • type

      Type type()
      Gets the Java Type this parameter type handles.
      Returns:
      the handled type.
    • resolve

      @Nullable T resolve(@NotNull @NotNull ExecutionContext<S> context, @NotNull @NotNull CommandInputStream<S> inputStream, @NotNull @NotNull String input) throws ImperatException
      Resolves the parameter value from the given input string, using the provided execution context and input stream.
      Parameters:
      context - the execution context.
      inputStream - the command input stream.
      input - the raw input string.
      Returns:
      the resolved value, or null if resolution fails.
      Throws:
      ImperatException - if resolution fails due to an error.
    • getSuggestionResolver

      SuggestionResolver<S> getSuggestionResolver()
      Gets the suggestion resolver for this parameter type.
      Returns:
      the suggestion resolver.
    • matchesInput

      boolean matchesInput(int rawPosition, Context<S> context, CommandParameter<S> parameter)
      Checks if the given input string matches this parameter type for the specified parameter.
      Parameters:
      rawPosition - the raw position of the argument in the input.
      context - the context to be matched.
      parameter - the command parameter.
      Returns:
      true if the input matches, false otherwise.
    • supplyDefaultValue

      @AvailableSince("1.9.1") default OptionalValueSupplier supplyDefaultValue()
      Returns the default value supplier for the given source and command parameter. By default, this returns an empty supplier, indicating no default value.
      Returns:
      an OptionalValueSupplier providing the default value, or empty if none.
    • isRelatedToType

      default boolean isRelatedToType(Type type)
      Checks if the given type is related to this parameter type.
      Parameters:
      type - the type to check.
      Returns:
      true if the types are related, false otherwise.
    • equalsExactly

      default boolean equalsExactly(Type type)
      Checks if the given type exactly matches this parameter type.
      Parameters:
      type - the type to check.
      Returns:
      true if the types match exactly, false otherwise.
    • withSuggestions

      @NotNull @NotNull ParameterType<S,T> withSuggestions(String... suggestions)
      Returns a new ParameterType instance with the specified suggestions.
      Parameters:
      suggestions - the suggestions to use.
      Returns:
      a new parameter type with suggestions.
    • wrappedType

      default TypeWrap<T> wrappedType()
      Gets a TypeWrap for the handled type.
      Returns:
      the wrapped type.
    • isGreedy

      @AvailableSince("2.1.0") default boolean isGreedy(CommandParameter<S> parameter)
      Determines if this parameter type is greedy, meaning it consumes multiple arguments. By default, returns false.
      Parameters:
      parameter - the command parameter.
      Returns:
      true if greedy, false otherwise.
    • getConsumedArguments

      @AvailableSince("2.1.0") default int getConsumedArguments()
      Returns the number of arguments consumed by this parameter type. By default, returns 1.
      Returns:
      the number of consumed arguments.