Class FunctionalInterfaceLoggingNameResolver
java.lang.Object
dk.cloudcreate.essentials.shared.reflection.FunctionalInterfaceLoggingNameResolver
Utility for resolving human-readable, meaningful names from functional interface implementations - also supports normal classes.
This class attempts to provide clear and informative names from lambda expressions and method references
for logging and debugging purposes, trying to avoid default obscure names like $$Lambda$123.
It uses several strategies to extract names, in order of preference:
- Functional interface information / class name
- Stack trace analysis
Implementation notes:
- Results are cached internally for performance
- Handles Java security restrictions gracefully
- Thread-safe implementation
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractClassNameFromLambda(String lambdaString) static StringresolveLoggingName(Object handler) Resolves a logging‐friendly name for the provided functional interface implementation - also supports normal classes.
-
Method Details
-
resolveLoggingName
Resolves a logging‐friendly name for the provided functional interface implementation - also supports normal classes.If the implementation is a lambda expression, this method attempts to extract the underlying implementation class and method via reflection. Otherwise, it falls back to the class's simple name. The result is cached per implementation class.
- Parameters:
handler- the functional interface implementation or class instance- Returns:
- a logging‐friendly name for diagnostic purposes
- Throws:
IllegalArgumentException- if the handler is null
-
extractClassNameFromLambda
-