Class WebParamParameterResolver

java.lang.Object
io.fluxcapacitor.javaclient.web.WebParamParameterResolver
All Implemented Interfaces:
ParameterResolver<HasMessage>

public class WebParamParameterResolver extends Object implements ParameterResolver<HasMessage>
Resolves method parameters in web handler methods based on meta-annotations derived from WebParam.

This resolver targets parameters in methods that handle MessageType.WEBREQUEST messages. It looks for parameters annotated with a concrete annotation that is itself meta-annotated with @WebParam, such as @PathParam, @QueryParam, or other custom parameter annotations used in web APIs.

The resolver extracts the desired parameter value from the associated WebRequestContext using the rules and source defined by the meta-annotation (e.g. from the path, query string, or headers).

To determine the parameter name to resolve, the following resolution strategy is used:

  • If @WebParam.value() is set, it is used directly.
  • Otherwise, if Java parameter names are available (compiled with -parameters) or if the method was compiled from Kotlin source, the parameter name is used.
  • If neither is available, the name is resolved from a generated ParameterRegistry class.

If the parameter cannot be found in the request, null is returned.

See Also:
  • Constructor Details

    • WebParamParameterResolver

      public WebParamParameterResolver()
  • Method Details

    • resolve

      public Function<HasMessage,Object> resolve(Parameter p, Annotation methodAnnotation)
      Resolves the parameter value from a WebRequestContext using the metadata provided by a parameter annotation that is meta-annotated with WebParam.

      The parameter name is determined based on the annotation value, Java reflection, or a generated ParameterRegistry, and the value is extracted from the request using the declared WebParameterSource (e.g. QUERY, PATH, HEADER).

      Specified by:
      resolve in interface ParameterResolver<HasMessage>
      Parameters:
      p - the method parameter to resolve
      methodAnnotation - the handler method annotation (not used here)
      Returns:
      a function that resolves the argument from the incoming HasMessage
    • matches

      public boolean matches(Parameter parameter, Annotation methodAnnotation, HasMessage value)
      Determines if this resolver is applicable to a given method parameter.

      This returns true if:

      Specified by:
      matches in interface ParameterResolver<HasMessage>
      Parameters:
      parameter - the method parameter
      methodAnnotation - the enclosing method annotation (not used here)
      value - the message passed to the handler
      Returns:
      true if the parameter is eligible for resolution