com.github.chengyuxing.sql.utils.XQLMapperUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rabbit-sql Show documentation
Show all versions of rabbit-sql Show documentation
Light wrapper of JDBC, support ddl, dml, query, plsql/procedure/function, transaction and manage sql
file.
package com.github.chengyuxing.sql.utils;
import com.github.chengyuxing.sql.XQLInvocationHandler;
import com.github.chengyuxing.sql.annotation.XQLMapper;
import java.lang.reflect.Proxy;
public class XQLMapperUtil {
@SuppressWarnings("unchecked")
public static T getProxyInstance(Class clazz, XQLInvocationHandler xqlInvocationHandler) throws IllegalAccessException {
if (!clazz.isInterface()) {
throw new IllegalAccessException("Not interface: " + clazz.getName());
}
if (!clazz.isAnnotationPresent(XQLMapper.class)) {
throw new IllegalAccessException(clazz + " should be annotated with @" + XQLMapper.class.getSimpleName());
}
return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, xqlInvocationHandler);
}
}