cn.schoolwow.quickdao.module.database.dql.subCondition.kit.LambdaSubConditionInvocationHandler Maven / Gradle / Ivy
package cn.schoolwow.quickdao.module.database.dql.subCondition.kit;
import cn.schoolwow.quickdao.domain.database.dql.subCondition.LambdaSubCondition;
import cn.schoolwow.quickdao.domain.database.dql.subCondition.SubCondition;
import cn.schoolwow.quickdao.util.LambdaUtils;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/**
* lambda表达式动态代理对象
*/
public class LambdaSubConditionInvocationHandler implements InvocationHandler {
private SubCondition subCondition;
public LambdaSubConditionInvocationHandler(SubCondition subCondition) {
this.subCondition = subCondition;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("done")) {
return this.subCondition;
}
Object result = LambdaUtils.invokeMethod(args, method, this.subCondition);
if (method.getName().equals("joinTable")) {
SubCondition subCondition = (SubCondition) result;
return subCondition.lambdaSubCondition();
} else if (method.getReturnType().getName().equals(LambdaSubCondition.class.getName())) {
return proxy;
} else {
return result;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy