Class MessageParameterResolver
- All Implemented Interfaces:
HandlerInputResolver<Object>, ParameterResolver<Object>, PreparedParameterResolver<Object>
DeserializingMessage.
This allows handler methods to access the deserialization context, including message metadata, payload, and raw serialized content.
Useful when advanced information about the message is needed, such as the Fluxzero-assigned message index.
-
Nested Class Summary
Nested classes/interfaces inherited from interface HandlerInputResolver
HandlerInputResolver.Resolution<M> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInputCacheKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Returns a key containing every input property that can affect whether this resolver matches the parameter and how the parameter value is resolved.booleanisNoMatchPayloadClassKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Returns whether an unmatched result is guaranteed to remain unmatched for every payload with the same runtime class.booleanisPayloadClassKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Returns whether the payload's runtime class alone determines this resolver's successful result for the supplied parameter.booleanmatches(Parameter parameter, Annotation methodAnnotation, Object value) Indicates whether the resolved value is compatible with the declared parameter type.booleanmayApply(Executable method, Class<?> targetClass) Returnstrueif this resolver might apply to the given method.prepare(Parameter parameter, Annotation methodAnnotation) Prepares a resolver function when this resolver can determine compatibility from the parameter and method annotation alone.prepareInput(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Determines whether this resolver handles the parameter and, when it does, creates the function that supplies the parameter value during invocation.resolve(Parameter p, Annotation methodAnnotation) Resolves aParameterof a handler method into a value function based on the given message.resolveIfPossible(Parameter parameter, Annotation methodAnnotation, Object value) Returns a prepared resolver for the given message, ornullwhen this resolver cannot handle the parameter.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ParameterResolver
determinesSpecificity, specificityPriority, test
-
Constructor Details
-
MessageParameterResolver
public MessageParameterResolver()
-
-
Method Details
-
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<Object>- 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.
-
prepare
Description copied from interface:ParameterResolverPrepares a resolver function when this resolver can determine compatibility from the parameter and method annotation alone.The default returns
null, which keeps resolution message-dependent. Implementations should override this only whenParameterResolver.matches(Parameter, Annotation, Object)would always betruefor the supplied parameter, regardless of the message instance. Dynamic resolvers such as payload, trigger, or entity resolvers should keep the default behavior.- Specified by:
preparein interfaceParameterResolver<Object>- Parameters:
parameter- the parameter to resolvemethodAnnotation- the annotation present on the handler method- Returns:
- a prepared resolver, or
nullwhen resolution must remain message-dependent
-
resolveIfPossible
public Function<Object,Object> resolveIfPossible(Parameter parameter, Annotation methodAnnotation, Object value) Description copied from interface:PreparedParameterResolverReturns a prepared resolver for the given message, ornullwhen this resolver cannot handle the parameter.- Specified by:
resolveIfPossiblein interfacePreparedParameterResolver<Object>
-
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<Object>- 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
-
mayApply
Description copied from interface:ParameterResolverReturnstrueif this resolver might apply to the given method. Implementations should perform only inexpensive checks and never throw.- Specified by:
mayApplyin interfaceParameterResolver<Object>- Parameters:
method- the handler method or constructortargetClass- the declaring or target class- Returns:
trueif this resolver could apply,falseotherwise
-
getInputCacheKey
public Object getInputCacheKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Description copied from interface:HandlerInputResolverReturns a key containing every input property that can affect whether this resolver matches the parameter and how the parameter value is resolved.Return
nullwhen no safe reusable key can be provided. Fluxzero will then fall back to normal per-message resolution. Keys are compared usingObject.equals(Object)and must be stable after they are returned.- Specified by:
getInputCacheKeyin interfaceHandlerInputResolver<Object>- Parameters:
parameter- the handler parameter to resolvemethodAnnotation- the annotation that marks the handler method, if presentrepresentative- an input representative of the group to be cached- Returns:
- a stable, complete cache key, or
nullto disable prepared resolution for this input
-
isPayloadClassKey
public boolean isPayloadClassKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Description copied from interface:HandlerInputResolverReturns whether the payload's runtime class alone determines this resolver's successful result for the supplied parameter.Return
trueonly if every payload of that class produces the same match decision and may use the same prepared resolver. This enables a faster class-based lookup.- Specified by:
isPayloadClassKeyin interfaceHandlerInputResolver<Object>- Returns:
trueif the result can safely be reused for every payload of the same runtime class
-
isNoMatchPayloadClassKey
public boolean isNoMatchPayloadClassKey(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Description copied from interface:HandlerInputResolverReturns whether an unmatched result is guaranteed to remain unmatched for every payload with the same runtime class.This is separate from
HandlerInputResolver.isPayloadClassKey(Parameter, Annotation, HandlerInput)because matching and non-matching inputs may require different cache guarantees.- Specified by:
isNoMatchPayloadClassKeyin interfaceHandlerInputResolver<Object>- Returns:
trueif the non-match can safely be reused for the entire payload class
-
prepareInput
public HandlerInputResolver.Resolution<Object> prepareInput(Parameter parameter, Annotation methodAnnotation, HandlerInput<Object> representative) Description copied from interface:HandlerInputResolverDetermines whether this resolver handles the parameter and, when it does, creates the function that supplies the parameter value during invocation.The result must agree with normal
ParameterResolverselection, including any contribution the resolver makes to handler specificity.- Specified by:
prepareInputin interfaceHandlerInputResolver<Object>- Parameters:
parameter- the handler parameter to resolvemethodAnnotation- the annotation that marks the handler method, if presentrepresentative- an input representative of the cache key returned for this parameter- Returns:
- an unmatched, rejected, or successfully resolved result
-