Interface ParameterResolver<M>
- Type Parameters:
M
- the type of message object used by the handler invocation context, oftenDeserializingMessage
- All Known Implementing Classes:
CurrentUserParameterResolver
,DeserializingMessageParameterResolver
,EntityParameterResolver
,InputParameterResolver
,MessageParameterResolver
,MetadataParameterResolver
,PayloadParameterResolver
,SpringBeanParameterResolver
,TriggerParameterResolver
,TypedParameterResolver
,UserParameterResolver
,WebParamParameterResolver
,WebPayloadParameterResolver
,WebsocketHandlerDecorator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
HandleEvent
,
HandleCommand
, etc.).
A ParameterResolver
determines how to inject values into the parameters of a handler method based on the
message being handled, the parameter type, and other context. This allows custom logic to inject fields such as the
payload
, metadata
, authenticated User
, or other derived values.
Custom ParameterResolver ParameterResolvers
can be registered with a FluxCapacitorBuilder
to
influence handler invocation logic across one or more message types.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Indicates whether this resolver contributes to determining handler method specificity when multiple handler candidates are available.default boolean
filterMessage
(M message, Parameter parameter) Determines whether a given message should be passed to a handler method based on this parameter's characteristics.default boolean
matches
(Parameter parameter, Annotation methodAnnotation, M value) Indicates whether the resolved value is compatible with the declared parameter type.resolve
(Parameter parameter, Annotation methodAnnotation) Resolves aParameter
of a handler method into a value function based on the given message.
-
Method Details
-
resolve
Resolves aParameter
of a handler method into a value function based on the given message.If the parameter cannot be resolved by this resolver and
matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is not implemented, this method must returnnull
.- Parameters:
parameter
- the parameter to resolvemethodAnnotation
- the annotation present on the handler method (e.g.,@HandleEvent
)- Returns:
- a function that takes a message and returns a value to be injected into the method parameter, or
null
if the parameter cannot be resolved andmatches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is not implemented.
-
matches
Indicates whether the resolved value is compatible with the declared parameter type.This method helps determine whether the parameter can be injected for a given message. It first invokes
resolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation)
and then verifies that the returned value (if any) is assignable to the parameter type.- Parameters:
parameter
- the parameter being checkedmethodAnnotation
- the annotation on the handler methodvalue
- the message instance to use for resolution- Returns:
true
if the parameter can be resolved and assigned to,false
otherwise
-
determinesSpecificity
default boolean determinesSpecificity()Indicates whether this resolver contributes to determining handler method specificity when multiple handler candidates are available.If
true
, the resolver will participate in determining the most specific handler for a message. This is relevant when the system must choose between overlapping handler signatures, e.g. for a resolver of a message's payload.- Returns:
true
if this resolver influences specificity decisions,false
otherwise
-
filterMessage
Determines whether a given message should be passed to a handler method based on this parameter's characteristics.This hook is used after
matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is invoked but beforeresolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation)
and can thus be used to prevent other parameter resolvers from supplying a candidate for parameter injection.- Parameters:
message
- the message being evaluatedparameter
- the method parameter to test- Returns:
true
if the message should be processed,false
if it should be filtered out
-