Class Invokers
java.lang.Object
pro.verron.officestamper.core.Invokers
- All Implemented Interfaces:
org.springframework.expression.MethodResolver
The Invokers class serves as an implementation of the MethodResolver interface.
It is designed to provide an efficient mechanism for resolving method executors based on method names and argument types.
The class organizes and stores registered invokers in a structured map, enabling streamlined method resolution at runtime.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents argument types associated with method invocation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InvokerCreates anInvokerfor a custom function.@Nullable org.springframework.expression.MethodExecutorresolve(org.springframework.expression.EvaluationContext context, Object targetObject, String name, List<org.springframework.core.convert.TypeDescriptor> argumentTypes) Resolves a method executor for a given method name and argument types within the specified context and target object.streamInvokersFromClass(Map<Class<?>, ?> interfaces2implementations) Transforms a map containing interface-to-implementation mappings into a stream ofInvokerobjects.
-
Constructor Details
-
Invokers
Constructs anInvokersinstance, grouping and mapping invokers by their names and argument types to their corresponding executors.- Parameters:
invokerStream- a stream ofInvokerobjects, where each invoker encapsulates the method name, its parameter types, and the associated method executor.
-
-
Method Details
-
streamInvokersFromClass
Transforms a map containing interface-to-implementation mappings into a stream ofInvokerobjects. Each entry in the map is processed to generate a flat stream of relevantInvokerinstances.- Parameters:
interfaces2implementations- a map where keys represent interface classes and values represent their corresponding implementations, used to derive invoker instances.- Returns:
- a stream of
Invokerobjects derived from the provided map entries.
-
ofCustomFunction
Creates anInvokerfor a custom function.- Parameters:
cf- the custom function.- Returns:
- the invoker.
-
resolve
public @Nullable org.springframework.expression.MethodExecutor resolve(org.springframework.expression.EvaluationContext context, Object targetObject, String name, List<org.springframework.core.convert.TypeDescriptor> argumentTypes) Resolves a method executor for a given method name and argument types within the specified context and target object. This method attempts to find a matching executor for methods registered with a specific name and compatible argument types.- Specified by:
resolvein interfaceorg.springframework.expression.MethodResolver- Parameters:
context- the evaluation context in which the method is being resolved, providing necessary state and configuration.targetObject- the object on which the resolved method will be invoked.name- the name of the method to resolve.argumentTypes- a list of type descriptors representing the argument types of the method to resolve.- Returns:
- the resolved
MethodExecutorif a compatible method is found; otherwise, returnsnull.
-