简介:
Gadtry 是一个构建于java8之上的工具库, 涵盖了Ioc Aop exec graph等等工具库,几乎涵盖了日常开发中非常多工具类,当然它还在不断丰富中.
Gadtry 1.2.0 已发布
使用:
<dependency> <groupId>com.github.harbby</groupId> <artifactId>gadtry</artifactId> <version>1.2.0</version> </dependency>
1.2.0版本主要加强Aop功能,具体如下:
对普通对象代理时正式支持方法过滤
returnType(Class<?>... returnTypes)过滤支持自动装拆箱
修复checkMethod 可能不生效的问题
普通对象代理:
T proxy = AopFactory.proxy(Class<T>)
.byInstance(instance)
.returnType(void.class, Boolean.class) --只代理返回void或bool类型的方法
//.methodAnnotated(Setter.class)
.around(proxyContext -> {
String name = proxyContext.getInfo().getName();
System.out.println(name);
Object value = proxyContext.proceed();
switch (name) {
case "add":
Assert.assertEquals(true, value); //Set or List
break;
case "size":
Assert.assertTrue(value instanceof Integer);
break;
}
});
1.1.1 版本修复checkMethod可能不生效的问题
更多细节请关注: https://gitee.com/mirrors/Gadtry
暂无更多评论