Class ConstrainedParameterTypeDecorator<S extends Source,T>

java.lang.Object
studio.mevera.imperat.util.TypeCapturer
studio.mevera.imperat.command.parameters.type.BaseParameterType<S,T>
studio.mevera.imperat.command.parameters.ConstrainedParameterTypeDecorator<S,T>
All Implemented Interfaces:
ParameterType<S,T>

public final class ConstrainedParameterTypeDecorator<S extends Source,T> extends BaseParameterType<S,T>
  • Method Details

    • of

      public static <S extends Source, T> ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S,T> original, Set<String> allowedValues, boolean caseSensitive)
    • of

      public static <S extends Source, T> ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S,T> original, Set<String> allowedValues)
    • resolve

      @Nullable public T resolve(@NotNull @NotNull ExecutionContext<S> context, @NotNull @NotNull CommandInputStream<S> commandInputStream, @NotNull @NotNull String input) throws ImperatException
      Description copied from interface: ParameterType
      Resolves the parameter value from the given input string, using the provided execution context and input stream.
      Parameters:
      context - the execution context.
      commandInputStream - 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

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

      public boolean isRelatedToType(Type type)
      Description copied from interface: ParameterType
      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

      public boolean equalsExactly(Type type)
      Description copied from interface: ParameterType
      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.
    • wrappedType

      public TypeWrap<T> wrappedType()
      Description copied from interface: ParameterType
      Gets a TypeWrap for the handled type.
      Returns:
      the wrapped type.
    • matchesInput

      public boolean matchesInput(int rawPosition, Context<S> context, CommandParameter<S> parameter)
      Description copied from class: BaseParameterType
      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>
      Overrides:
      matchesInput in class BaseParameterType<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)
      Description copied from class: BaseParameterType
      Adds the provided suggestions to the current list of suggestions for this parameter type.
      Specified by:
      withSuggestions in interface ParameterType<S extends Source,T>
      Overrides:
      withSuggestions in class BaseParameterType<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.