Class ParameterRegistry

java.lang.Object
io.fluxcapacitor.common.reflection.ParameterRegistry
Direct Known Subclasses:
StaticFileHandler_params

public abstract class ParameterRegistry extends Object
Registry for accessing method parameter names at runtime in environments where Java reflection does not retain them (e.g. Java applications compiled without debug information).

This class works in tandem with annotation processors, which generate a companion _params class per handler class at compile time (see e.g.: WebParameterProcessor). The generated class extends this ParameterRegistry and provides a static map from method signatures to parameter name lists.

At runtime, the framework uses this registry to retrieve parameter names for handler methods annotated with web-related annotations such as @QueryParam, @PathParam, etc. This is especially important for Java applications, where parameter names are not always available through standard reflection.

For example, given a method:


 public void getUser(@PathParam("id") String userId) { ... }
 
the generated registry allows the framework to resolve "userId" even if it's not available via reflection.

Key Features

  • Loads generated registries dynamically using class naming conventions
  • Provides lookup by Executable or Parameter
  • Memoizes results for performance
  • Uses method signature format: methodName(paramType1,paramType2)

Internal Use Only

This utility is not intended for application developers to use directly. It is used internally by Flux Capacitor's web framework components.
  • Constructor Details

    • ParameterRegistry

      public ParameterRegistry()
  • Method Details

    • getParameterNames

      public List<String> getParameterNames(Executable method)
      Retrieves the parameter names for a given method.
      Parameters:
      method - the reflective Executable (method or constructor)
      Returns:
      the list of parameter names, in declaration order
      Throws:
      IllegalStateException - if no parameter names are found
    • getParameterName

      public String getParameterName(Parameter parameter)
      Retrieves the name of a specific method parameter.
      Parameters:
      parameter - the Parameter to look up
      Returns:
      the parameter name, as recorded in the generated registry
    • of

      public static ParameterRegistry of(Class<?> type)
      Returns the registry instance for the specified class, loading and memoizing the generated _params class on first access.
      Parameters:
      type - the source class for which to obtain a registry
      Returns:
      the corresponding ParameterRegistry instance
    • signature

      public static String signature(ExecutableElement method)
      Generates a string representation of a method signature using compile-time elements.
      Parameters:
      method - the method element
      Returns:
      a signature string in the format methodName(paramType1,paramType2)
    • signature

      public static String signature(Executable method)
      Generates a string representation of a method signature using a runtime reflection Executable.
      Parameters:
      method - the method or constructor
      Returns:
      a signature string in the format methodName(paramType1,paramType2)