Interface KeyedParameterResolver<M>

Type Parameters:
M - message type accepted by the resolver
All Superinterfaces:
ParameterResolver<M>
All Known Implementing Classes:
PayloadParameterResolver, TriggerParameterResolver

public interface KeyedParameterResolver<M> extends ParameterResolver<M>
Optional extension for dynamic parameter resolvers whose applicability can be safely reused for messages with the same low-cardinality key.

The key must fully describe every message-dependent fact used to decide whether this resolver matches or rejects the parameter. The returned KeyedParameterResolver.Resolution.resolver() must be thread-safe and reusable for every message that produces an equal key; it must never capture the representative message or a value obtained from it. Returning null from getCacheKey(Object) disables caching for that message.

Resolved parameter values themselves are never cached. Handler matching only caches the resolution recipe and applies its value resolver to the current message.

  • Method Details

    • getCacheKey

      Object getCacheKey(M value)
      Returns an immutable, equality-stable and preferably low-cardinality applicability key.
      Parameters:
      value - current message
      Returns:
      cache key, or null when this message must be evaluated dynamically
    • isCacheKeyRelevant

      default boolean isCacheKeyRelevant(Parameter parameter, Annotation methodAnnotation)
      Returns whether this resolver's key can affect applicability for the supplied parameter.

      Returning false promises that resolveForKey(Parameter, Annotation, M, Object) always returns KeyedParameterResolver.Resolution.unmatched() for this parameter. This lets handler-level selection caches omit irrelevant resolver keys.

    • resolveForKey

      KeyedParameterResolver.Resolution<M> resolveForKey(Parameter parameter, Annotation methodAnnotation, M value, Object cacheKey)
      Computes a reusable resolution recipe for the supplied key.
      Parameters:
      parameter - handler method parameter
      methodAnnotation - handler method annotation
      value - representative message for the key
      cacheKey - key returned by getCacheKey(Object)
      Returns:
      reusable resolution outcome