Class ParameterRegistry
java.lang.Object
io.fluxcapacitor.common.reflection.ParameterRegistry
- Direct Known Subclasses:
StaticFileHandler_params
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
orParameter
- 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetParameterName
(Parameter parameter) Retrieves the name of a specific method parameter.getParameterNames
(Executable method) Retrieves the parameter names for a given method.static ParameterRegistry
Returns the registry instance for the specified class, loading and memoizing the generated_params
class on first access.static String
signature
(Executable method) Generates a string representation of a method signature using a runtime reflectionExecutable
.static String
signature
(ExecutableElement method) Generates a string representation of a method signature using compile-time elements.
-
Constructor Details
-
ParameterRegistry
public ParameterRegistry()
-
-
Method Details
-
getParameterNames
Retrieves the parameter names for a given method.- Parameters:
method
- the reflectiveExecutable
(method or constructor)- Returns:
- the list of parameter names, in declaration order
- Throws:
IllegalStateException
- if no parameter names are found
-
getParameterName
Retrieves the name of a specific method parameter.- Parameters:
parameter
- theParameter
to look up- Returns:
- the parameter name, as recorded in the generated registry
-
of
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
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
Generates a string representation of a method signature using a runtime reflectionExecutable
.- Parameters:
method
- the method or constructor- Returns:
- a signature string in the format
methodName(paramType1,paramType2)
-