AnnotatedMethodArgumentResolver class final
Resolves parameters of handler methods annotated with request parameter annotations in JetLeaf's web request handling system.
An AnnotatedMethodArgumentResolver is responsible for:
- Inspecting method parameters at runtime.
- Detecting annotations that are either RequestParameter or annotated with RequestParameter.
- Locating a corresponding Resolver (via ResolvedBy) to extract values from the ServerHttpRequest.
This resolver allows developers to define custom parameter resolution strategies using annotations on method parameters, enabling a clean separation between controller logic and request parsing.
Resolution Workflow
- Annotation Discovery: Collects all direct annotations on a parameter.
- Type Matching: Checks if an annotation is a RequestParameter or is meta-annotated with RequestParameter.
- Resolver Extraction: Looks for a ResolvedBy annotation on the annotation class to retrieve the resolver instance.
- Value Resolution: Uses the resolver to extract the argument value from the incoming request.
- Returns
nullif no suitable resolver is found.
Example
class UserController {
void getUser(
@RequestParam('id') String id,
@RequestParam('verbose') bool verbose
) {}
}
final resolver = AnnotatedMethodArgumentResolver();
final param = HandlerMethod(UserController.getUser).getParameter('id');
final value = await resolver.resolveArgument(param, request, response, handler);
Design Notes
- This class is stateless and can be reused across multiple requests.
- Supports annotation-driven parameter resolution via RequestParameter and ResolvedBy.
- Reflection failures while inspecting annotation metadata are silently ignored, ensuring robust request handling.
- Designed for internal use in the JetLeaf request dispatch pipeline.
- Implemented types
Constructors
- AnnotatedMethodArgumentResolver(ResolverContext _context)
-
Resolves parameters of handler methods annotated with request parameter
annotations in JetLeaf's web request handling system.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canResolve(
Parameter param) → bool -
Returns
trueif this resolver supports the givenparam.override -
getResolver(
Source source) → Resolver? -
Retrieves the Resolver associated with a given
source(parameter). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveArgument(
Parameter param, ServerHttpRequest req, ServerHttpResponse res, HandlerMethod handler, [Object? ex, StackTrace? st]) → Future< Object?> -
Resolves the argument value for the given
param.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited