io.github.afezeria.freedao.classic.runtime.context.DaoContext Maven / Gradle / Ivy
package io.github.afezeria.freedao.classic.runtime.context;
import io.github.afezeria.freedao.classic.runtime.ResultHandler;
import io.github.afezeria.freedao.classic.runtime.SqlExecutor;
import io.github.afezeria.freedao.classic.runtime.SqlSignature;
import javax.sql.DataSource;
import java.sql.Connection;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
/**
*
*/
public abstract class DaoContext {
private DaoContext delegate;
public synchronized void setDelegate(DaoContext delegate) {
Objects.requireNonNull(delegate);
if (this.delegate == null) {
this.delegate = delegate;
}
}
public DaoContext getDelegate() {
if (delegate == null) {
throw new IllegalStateException("uninitialized context");
}
return delegate;
}
public T withConnection(Function supplier) {
return getDelegate().withConnection(supplier);
}
public Object[] buildSql(SqlSignature, ?> signature, Object[] args, Function