Class BaseParameterType<S extends Source,T>

java.lang.Object
studio.mevera.imperat.util.TypeCapturer
studio.mevera.imperat.command.parameters.type.BaseParameterType<S,T>
Type Parameters:
S - The type of the source from which the command originates.
T - The type of the parameter being handled.
All Implemented Interfaces:
ParameterType<S,T>
Direct Known Subclasses:
ConstrainedParameterTypeDecorator, ParameterArray, ParameterBoolean, ParameterCollection, ParameterCommand, ParameterCompletableFuture, ParameterEnum, ParameterFlag, ParameterMap, ParameterNumber, ParameterOptional, ParameterString, ParameterUUID

public abstract class BaseParameterType<S extends Source,T> extends TypeCapturer implements ParameterType<S,T>
Base class for defining parameter types in a command processing framework. This class handles the basic functionality for managing type information and suggestions for parameters.
  • Field Details

    • type

      protected final Type type
      Encapsulates type information for the parameter being handled. This instance is used to collect and manage type-related information and operations specific to the parameter type.
    • suggestions

      protected final List<String> suggestions
      A list storing suggestions for parameter types in a command processing framework.
  • Constructor Details

    • BaseParameterType

      public BaseParameterType()
      Constructs a new BaseParameterType with an automated TypeWrap
    • BaseParameterType

      public BaseParameterType(Class<T> type)
      Constructs a new BaseParameterType with the given TypeWrap.
      Parameters:
      type - The type of the parameter.
    • BaseParameterType

      public BaseParameterType(Type type)
      Constructs a new BaseParameterType with the given TypeWrap.
      Parameters:
      type - The type of the parameter.
  • Method Details

    • type

      public Type type()
      Retrieves the Type associated with this BaseParameterType.
      Specified by:
      type in interface ParameterType<S extends Source,T>
      Returns:
      the Type associated with this parameter type.
    • getSuggestionResolver

      public SuggestionResolver<S> getSuggestionResolver()
      Returns the suggestion resolver associated with this parameter type.
      Specified by:
      getSuggestionResolver in interface ParameterType<S extends Source,T>
      Returns:
      the suggestion resolver for generating suggestions based on the parameter type.
    • matchesInput

      public boolean matchesInput(int rawPosition, Context<S> context, CommandParameter<S> parameter)
      Determines whether the provided input matches the expected format or criteria for a given command parameter. this is used during CommandTree.contextMatch(Context, ArgumentInput)
      Specified by:
      matchesInput in interface ParameterType<S extends Source,T>
      Parameters:
      rawPosition - The raw position of the argument in the input.
      context - The context to be matched, providing necessary information about the command execution environment.
      parameter - The command parameter that provides context for the input handling.
      Returns:
      true if the input matches the expected criteria; false otherwise.
    • withSuggestions

      @NotNull public @NotNull ParameterType<S,T> withSuggestions(String... suggestions)
      Adds the provided suggestions to the current list of suggestions for this parameter type.
      Specified by:
      withSuggestions in interface ParameterType<S extends Source,T>
      Parameters:
      suggestions - The array of suggestions to be added.
      Returns:
      The current instance of the parameter type with the added suggestions.