Interface ParameterResolver<M>
- Type Parameters:
M- the type of message object used by the handler invocation context, oftenDeserializingMessage
- All Known Implementing Classes:
CurrentUserParameterResolver, EntityParameterResolver, InputParameterResolver, JsonPayloadParameterResolver, 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 FluxzeroBuilder to influence
handler invocation logic across one or more message types.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanIndicates whether this resolver contributes to determining handler method specificity when multiple handler candidates are available.default booleanmatches(Parameter parameter, Annotation methodAnnotation, M value) Indicates whether the resolved value is compatible with the declared parameter type.default booleanmayApply(Executable method, Class<?> targetClass) Returnstrueif this resolver might apply to the given method.resolve(Parameter parameter, Annotation methodAnnotation) Resolves aParameterof a handler method into a value function based on the given message.default booleanDetermines whether a given message should be passed to a handler method based on this parameter's characteristics.
-
Method Details
-
resolve
Resolves aParameterof a handler method into a value function based on the given message.If the parameter cannot be resolved by this resolver and
matches(Parameter, 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
nullif the parameter cannot be resolved andmatches(Parameter, 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(Parameter, 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:
trueif the parameter can be resolved and assigned to,falseotherwise
-
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:
trueif this resolver influences specificity decisions,falseotherwise
-
test
Determines whether a given message should be passed to a handler method based on this parameter's characteristics.This hook is used after
matches(Parameter, Annotation, M)is invoked but beforeresolve(Parameter, 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:
trueif the message should be processed,falseif it should be filtered out
-
mayApply
Returnstrueif this resolver might apply to the given method. Implementations should perform only inexpensive checks and never throw.- Parameters:
method- the handler method or constructortargetClass- the declaring or target class- Returns:
trueif this resolver could apply,falseotherwise
-