Class SimpleTypeResolver<S extends CommandSource,T>
java.lang.Object
studio.mevera.imperat.command.arguments.type.SimpleTypeResolver<S,T>
- Type Parameters:
S- the source typeT- the argument type
- All Implemented Interfaces:
ArgumentTypeHandler<S>,Prioritizable
public final class SimpleTypeResolver<S extends CommandSource,T>
extends Object
implements ArgumentTypeHandler<S>
An
ArgumentTypeHandler that wraps a simple Supplier for non-generic types.
This handler is used for basic types like String, Boolean, UUID, etc.,
where the resolution doesn't require any recursive type lookups.
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleTypeResolver(@NotNull Type targetType, @NotNull Supplier<ArgumentType<S, T>> supplier) Creates a new SimpleTypeResolver withPriority.HIGH.SimpleTypeResolver(@NotNull Type targetType, @NotNull Supplier<ArgumentType<S, T>> supplier, @NotNull Priority priority) Creates a new SimpleTypeResolver with the specified priority.SimpleTypeResolver(@NotNull Type targetType, @NotNull Supplier<ArgumentType<S, T>> supplier, @NotNull Priority priority, boolean matchRelated) Creates a new SimpleTypeResolver with full configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if this handler can resolve the given type.@NotNull PriorityReturns the target type this resolver handles.<R> @Nullable ArgumentType<S,R> resolve(@NotNull Type type, @NotNull TypeWrap<?> wrap, @NotNull ArgumentTypeLookup<S> lookup) Resolves anArgumentTypefor the given type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.imperat.command.arguments.type.ArgumentTypeHandler
onRegisteringResolver
-
Constructor Details
-
SimpleTypeResolver
public SimpleTypeResolver(@NotNull @NotNull Type targetType, @NotNull @NotNull Supplier<ArgumentType<S, T>> supplier) Creates a new SimpleTypeResolver withPriority.HIGH.- Parameters:
targetType- the type this resolver handlessupplier- the supplier that creates ArgumentType instances
-
SimpleTypeResolver
public SimpleTypeResolver(@NotNull @NotNull Type targetType, @NotNull @NotNull Supplier<ArgumentType<S, T>> supplier, @NotNull @NotNull Priority priority) Creates a new SimpleTypeResolver with the specified priority.- Parameters:
targetType- the type this resolver handlessupplier- the supplier that creates ArgumentType instancespriority- the priority of this resolver
-
SimpleTypeResolver
public SimpleTypeResolver(@NotNull @NotNull Type targetType, @NotNull @NotNull Supplier<ArgumentType<S, T>> supplier, @NotNull @NotNull Priority priority, boolean matchRelated) Creates a new SimpleTypeResolver with full configuration.- Parameters:
targetType- the type this resolver handlessupplier- the supplier that creates ArgumentType instancespriority- the priority of this resolvermatchRelated- if true, also matches subtypes of the target type
-
-
Method Details
-
canHandle
Description copied from interface:ArgumentTypeHandlerDetermines if this handler can resolve the given type.- Specified by:
canHandlein interfaceArgumentTypeHandler<S extends CommandSource>- Parameters:
type- the raw type to checkwrap- the wrapped type for convenience, providing additional type introspection- Returns:
- true if this handler can handle the type
-
resolve
@Nullable public <R> @Nullable ArgumentType<S,R> resolve(@NotNull @NotNull Type type, @NotNull @NotNull TypeWrap<?> wrap, @NotNull @NotNull ArgumentTypeLookup<S> lookup) Description copied from interface:ArgumentTypeHandlerResolves anArgumentTypefor the given type.This method is called only if
ArgumentTypeHandler.canHandle(Type, TypeWrap)returns true. The providedArgumentTypeLookupcan be used to recursively resolve component types for generic types (e.g., the element type of a collection).- Specified by:
resolvein interfaceArgumentTypeHandler<S extends CommandSource>- Type Parameters:
R- the resolved type- Parameters:
type- the type to resolvewrap- the wrapped type for conveniencelookup- the lookup function for resolving nested/component types- Returns:
- the resolved ArgumentType, or null if resolution fails despite canHandle returning true
-
getPriority
- Specified by:
getPriorityin interfacePrioritizable
-
getTargetType
Returns the target type this resolver handles.- Returns:
- the target type
-