Class UserParameterResolver

java.lang.Object
io.fluxzero.common.handling.TypedParameterResolver<Object>
io.fluxzero.sdk.tracking.handling.authentication.UserParameterResolver
All Implemented Interfaces:
ParameterResolver<Object>

public class UserParameterResolver extends TypedParameterResolver<Object>
Resolves parameters of type User, typically representing the current user in a request context.

This resolver delegates the extraction of user information to a configured UserProvider, which defines how to extract a user from a HasMessage or DeserializingMessage.

If no user can be determined from the message context, the User.getCurrent() thread-local fallback is used.

  • Constructor Details

    • UserParameterResolver

      public UserParameterResolver(@NonNull @NonNull UserProvider userProvider)
  • Method Details

    • resolve

      public Function<Object,Object> resolve(Parameter p, Annotation methodAnnotation)
      Description copied from interface: ParameterResolver
      Resolves a Parameter 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(Parameter, Annotation, M) is not implemented, this method must return null.

      Parameters:
      p - the parameter to resolve
      methodAnnotation - 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 and ParameterResolver.matches(Parameter, Annotation, M) is not implemented.
    • prepare

      public Function<Object,Object> prepare(Parameter parameter, Annotation methodAnnotation)
      Description copied from interface: ParameterResolver
      Prepares 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 when ParameterResolver.matches(Parameter, Annotation, Object) would always be true for the supplied parameter, regardless of the message instance. Dynamic resolvers such as payload, trigger, or entity resolvers should keep the default behavior.

      Parameters:
      parameter - the parameter to resolve
      methodAnnotation - the annotation present on the handler method
      Returns:
      a prepared resolver, or null when resolution must remain message-dependent