Class PayloadParameterResolver
- All Implemented Interfaces:
ParameterResolver<HasMessage>
This resolver matches a parameter when its declared type is assignable from the actual payload class of the incoming message.
This resolver is typically used in conjunction with filters such as PayloadFilter
to determine
handler compatibility based on payload types.
Special care is taken to allow null payloads for parameters that are declared nullable, which can occur during upcasting or transformation pipelines.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.boolean
filterMessage
(HasMessage message, Parameter parameter) Determines whether a given message should be passed to a handler method based on this parameter's characteristics.boolean
matches
(Parameter p, Annotation methodAnnotation, HasMessage value) Indicates whether the resolved value is compatible with the declared parameter type.resolve
(Parameter p, Annotation methodAnnotation) Resolves aParameter
of a handler method into a value function based on the given message.
-
Constructor Details
-
PayloadParameterResolver
public PayloadParameterResolver()
-
-
Method Details
-
matches
Description copied from interface:ParameterResolver
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
ParameterResolver.resolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation)
and then verifies that the returned value (if any) is assignable to the parameter type.- Specified by:
matches
in interfaceParameterResolver<HasMessage>
- Parameters:
p
- 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
-
resolve
Description copied from interface:ParameterResolver
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
ParameterResolver.matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is not implemented, this method must returnnull
.- Specified by:
resolve
in interfaceParameterResolver<HasMessage>
- Parameters:
p
- 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 andParameterResolver.matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is not implemented.
-
filterMessage
Description copied from interface:ParameterResolver
Determines whether a given message should be passed to a handler method based on this parameter's characteristics.This hook is used after
ParameterResolver.matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is invoked but beforeParameterResolver.resolve(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.- Specified by:
filterMessage
in interfaceParameterResolver<HasMessage>
- 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
-
determinesSpecificity
public boolean determinesSpecificity()Indicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.This is useful when more than one method matches a message, and the framework must decide which method is more specific. If this returns
true
, the resolver's presence and compatibility with the parameter may influence which handler is selected.- Specified by:
determinesSpecificity
in interfaceParameterResolver<HasMessage>
- Returns:
- true, signaling that this resolver helps determine method specificity
-