Class SourceCodeParameterNameResolver
- java.lang.Object
-
- io.testomat.junit.extractor.strategy.SourceCodeParameterNameResolver
-
public class SourceCodeParameterNameResolver extends java.lang.ObjectCentralized resolver for extracting parameter names from source code. Uses JavaParser to parse method signatures and extract actual parameter names.Features: - Thread-safe caching for performance - Fallback to reflection-based names when source parsing fails - Integration with existing FileFinder and FileParser infrastructure - Robust error handling and logging
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Clears the parameter name cache.intgetCacheSize()Gets cache statistics for monitoring and debugging.static SourceCodeParameterNameResolvergetInstance()java.lang.StringgetParameterName(java.lang.reflect.Method method, int parameterIndex)Gets a single parameter name by index, with appropriate fallback.java.util.List<java.lang.String>resolveParameterNames(java.lang.reflect.Method method)Resolves parameter names for a given method, using source code parsing when possible.
-
-
-
Method Detail
-
getInstance
public static SourceCodeParameterNameResolver getInstance()
-
resolveParameterNames
public java.util.List<java.lang.String> resolveParameterNames(java.lang.reflect.Method method)
Resolves parameter names for a given method, using source code parsing when possible. Falls back to reflection-based names if source parsing fails.- Parameters:
method- the method to resolve parameter names for- Returns:
- list of parameter names, or empty list if method is null
-
getParameterName
public java.lang.String getParameterName(java.lang.reflect.Method method, int parameterIndex)Gets a single parameter name by index, with appropriate fallback.- Parameters:
method- the method to get parameter name forparameterIndex- the index of the parameter (0-based)- Returns:
- the parameter name, or "param{index}" as ultimate fallback
-
clearCache
public void clearCache()
Clears the parameter name cache. Useful for testing or memory management.
-
getCacheSize
public int getCacheSize()
Gets cache statistics for monitoring and debugging.- Returns:
- the current number of cached parameter name entries
-
-