com.baidu.unbiz.fluentvalidator
类 ClosureHandler<T>
java.lang.Object
com.baidu.unbiz.fluentvalidator.ClosureHandler<T>
- 所有已实现的接口:
- Closure<T>
public abstract class ClosureHandler<T>
- extends Object
- implements Closure<T>
仿闭包,接口中的 execute(Object...) 通过回调模拟闭包
在实际应用中,在验证器内部会调用一些比较耗时操作,例如远程rpc或者数据库调用,而实际结果是可以在线程内共享的,
并供其他业务逻辑使用的。
在调用发起点,构造闭包,延迟调用到验证逻辑中,同时该闭包缓存了结果对象,那么在调用发起点即可通过Closure.getResult()获取结果对象。
- 作者:
- zhangxu
| 从类 java.lang.Object 继承的方法 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClosureHandler
public ClosureHandler()
execute
public void execute(Object... input)
- 从接口
Closure 复制的描述
- Performs an action on the specified input object.
- 指定者:
- 接口
Closure<T> 中的 execute
- 参数:
input - the input to execute on
doExecute
public abstract void doExecute(Object... input)
- 实际闭包执行逻辑
- 参数:
input - the input to execute on
executeAndGetResult
public T executeAndGetResult(Object... input)
- 从接口
Closure 复制的描述
- Wrap
Closure.execute(Object...) and Closure.getResult()
- 指定者:
- 接口
Closure<T> 中的 executeAndGetResult
- 参数:
input - the input to execute on
- 返回:
- result object
Copyright © 2015–2016 neoremind. All rights reserved.