public class MethodArgumentAutoOperateSupport extends Object
一个用于在方法调用前,根据AutoOperate注解的配置,对方法参数进行填充的辅助类。
在方法调用前,其将会把方法参数解析为一个需要进行填充的元素,
方法参数对应的AutoOperateAnnotatedElement数组将会被缓存,避免重复解析。
当方法被调用时,辅助类将根据配置对方法参数进行填充。
辅助类支持通过AutoOperate.condition()设置的条件表达式,
每次执行时都会通过MethodBasedExpressionEvaluator来进行求值,
只有当表达式返回true或者 "true" 字符串时,才会执行填充。
Support class for completing the operation of data
from the method parameters which annotated by AutoOperate
before the method is called.
Before the method is called, the method parameters will be resolved
to AutoOperateAnnotatedElement array by AutoOperateAnnotatedElement,
and then the AutoOperateAnnotatedElement array will be cached.
When the method is called, the AutoOperateAnnotatedElement array
will be used to complete the operation of data from the method parameters.
Support expression for AutoOperate.condition(), if the expression is not empty,
the expression will be evaluated by MethodBasedExpressionEvaluator,
only when the expression returns true or "true", the operation will be applied.
AutoOperateAnnotatedElementResolver,
MethodBasedExpressionEvaluator,
AutoOperate,
ArgAutoOperate| 限定符和类型 | 字段和说明 |
|---|---|
protected AnnotationFinder |
annotationFinder |
protected AutoOperateAnnotatedElementResolver |
elementResolver |
protected static AutoOperateAnnotatedElement[] |
EMPTY_ELEMENTS |
protected MethodBasedExpressionEvaluator |
expressionEvaluator |
protected Map<Method,AutoOperateAnnotatedElement[]> |
methodParameterCaches |
protected ParameterNameFinder |
parameterNameFinder |
| 构造器和说明 |
|---|
MethodArgumentAutoOperateSupport(AutoOperateAnnotatedElementResolver elementResolver,
MethodBasedExpressionEvaluator expressionEvaluator,
ParameterNameFinder parameterNameFinder,
AnnotationFinder annotationFinder)
Create a
MethodArgumentAutoOperateSupport instance. |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
beforeMethodInvoke(Method method,
Object[] args)
Before the method is called, process the input parameters
of the method according to the configuration of
ArgAutoOperate or AutoOperate annotation. |
void |
destroy()
Clear resources when destroying the bean.
|
protected void |
processArguments(Method method,
Object[] args,
AutoOperateAnnotatedElement[] autoOperateAnnotatedElements)
Processing method input arguments.
|
protected AutoOperateAnnotatedElement[] |
resolveParameters(Method method)
Analyze the annotations on methods and method parameters
to obtain the operation configuration of method parameters.
|
protected static final AutoOperateAnnotatedElement[] EMPTY_ELEMENTS
protected final AutoOperateAnnotatedElementResolver elementResolver
protected final Map<Method,AutoOperateAnnotatedElement[]> methodParameterCaches
protected final ParameterNameFinder parameterNameFinder
protected final AnnotationFinder annotationFinder
protected final MethodBasedExpressionEvaluator expressionEvaluator
public MethodArgumentAutoOperateSupport(AutoOperateAnnotatedElementResolver elementResolver, MethodBasedExpressionEvaluator expressionEvaluator, ParameterNameFinder parameterNameFinder, AnnotationFinder annotationFinder)
MethodArgumentAutoOperateSupport instance.elementResolver - element handlerexpressionEvaluator - expression evaluator delegateparameterNameFinder - parameter name finderannotationFinder - annotation finderpublic final void beforeMethodInvoke(Method method, Object[] args)
ArgAutoOperate or AutoOperate annotation.method - methodargs - argsprotected void processArguments(Method method, Object[] args, AutoOperateAnnotatedElement[] autoOperateAnnotatedElements)
method - methodargs - argsautoOperateAnnotatedElements - resolved elementsprotected AutoOperateAnnotatedElement[] resolveParameters(Method method)
method - methodEMPTY_ELEMENTSEMPTY_ELEMENTSpublic void destroy()
Copyright © 2024. All rights reserved.