Class MapArgumentTypeHandler<S extends CommandSource>

java.lang.Object
studio.mevera.imperat.command.arguments.type.handlers.MapArgumentTypeHandler<S>
Type Parameters:
S - the source type
All Implemented Interfaces:
ArgumentTypeHandler<S>, Prioritizable

public final class MapArgumentTypeHandler<S extends CommandSource> extends Object implements ArgumentTypeHandler<S>
Handler for resolving ArgumentType instances for Map types.

This handler supports all standard Java map implementations and allows registration of custom map initializers.

  • Constructor Details

    • MapArgumentTypeHandler

      public MapArgumentTypeHandler()
      Creates a new MapArgumentTypeHandler with default initializers.
  • Method Details

    • registerInitializer

      public <M extends Map<?, ?>> void registerInitializer(@NotNull @NotNull Class<M> type, @NotNull @NotNull Supplier<M> supplier)
      Registers a custom map initializer.
      Type Parameters:
      M - the map type
      Parameters:
      type - the map type
      supplier - the supplier that creates new instances
    • canHandle

      public boolean canHandle(@NotNull @NotNull Type type, @NotNull @NotNull TypeWrap<?> wrap)
      Description copied from interface: ArgumentTypeHandler
      Determines if this handler can resolve the given type.
      Specified by:
      canHandle in interface ArgumentTypeHandler<S extends CommandSource>
      Parameters:
      type - the raw type to check
      wrap - the wrapped type for convenience, providing additional type introspection
      Returns:
      true if this handler can handle the type
    • resolve

      @NotNull public <T> @NotNull ArgumentType<S,T> resolve(@NotNull @NotNull Type type, @NotNull @NotNull TypeWrap<?> wrap, @NotNull @NotNull ArgumentTypeLookup<S> lookup)
      Description copied from interface: ArgumentTypeHandler
      Resolves an ArgumentType for the given type.

      This method is called only if ArgumentTypeHandler.canHandle(Type, TypeWrap) returns true. The provided ArgumentTypeLookup can be used to recursively resolve component types for generic types (e.g., the element type of a collection).

      Specified by:
      resolve in interface ArgumentTypeHandler<S extends CommandSource>
      Type Parameters:
      T - the resolved type
      Parameters:
      type - the type to resolve
      wrap - the wrapped type for convenience
      lookup - the lookup function for resolving nested/component types
      Returns:
      the resolved ArgumentType, or null if resolution fails despite canHandle returning true
    • getPriority

      @NotNull public @NotNull Priority getPriority()
      Specified by:
      getPriority in interface Prioritizable