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 TypeMethodDescriptionbooleanIndicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.booleanmatches(Parameter p, Annotation methodAnnotation, HasMessage value) Indicates whether the resolved value is compatible with the declared parameter type.resolve(Parameter p, Annotation methodAnnotation) Resolves aParameterof a handler method into a value function based on the given message.booleantest(HasMessage message, Parameter parameter) Determines whether a given message should be passed to a handler method based on this parameter's characteristics.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ParameterResolver
mayApply
-
Constructor Details
-
PayloadParameterResolver
public PayloadParameterResolver()
-
-
Method Details
-
matches
Description copied from interface:ParameterResolverIndicates 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(Parameter, Annotation)and then verifies that the returned value (if any) is assignable to the parameter type.- Specified by:
matchesin interfaceParameterResolver<HasMessage>- Parameters:
p- the parameter being checkedmethodAnnotation- the annotation on the handler methodvalue- the message instance to use for resolution- Returns:
trueif the parameter can be resolved and assigned to,falseotherwise
-
resolve
Description copied from interface:ParameterResolverResolves aParameterof a handler method into a value function based on the given message.If the parameter cannot be resolved by this resolver and
ParameterResolver.matches(Parameter, Annotation, M)is not implemented, this method must returnnull.- Specified by:
resolvein 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
nullif the parameter cannot be resolved andParameterResolver.matches(Parameter, Annotation, M)is not implemented.
-
test
Description copied from interface:ParameterResolverDetermines whether a given message should be passed to a handler method based on this parameter's characteristics.This hook is used after
ParameterResolver.matches(Parameter, Annotation, M)is invoked but beforeParameterResolver.resolve(Parameter, Annotation)and can thus be used to prevent other parameter resolvers from supplying a candidate for parameter injection.- Specified by:
testin interfaceParameterResolver<HasMessage>- Parameters:
message- the message being evaluatedparameter- the method parameter to test- Returns:
trueif the message should be processed,falseif 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:
determinesSpecificityin interfaceParameterResolver<HasMessage>- Returns:
- true, signaling that this resolver helps determine method specificity
-