
jio.jdbc.QueryStmBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jio-jdbc Show documentation
Show all versions of jio-jdbc Show documentation
Functional and reactive JDBC client in Java
package jio.jdbc;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
public final class QueryStmBuilder implements Supplier>> {
private static final int DEFAULT_FETCH_SIZE = 1000;
private final String sqlQuery;
private final ParamsSetter setter;
private final ResultSetMapper mapper;
private int fetchSize = DEFAULT_FETCH_SIZE;
private boolean enableJFR = true;
private QueryStmBuilder(String sqlQuery, ParamsSetter setter, ResultSetMapper mapper) {
this.sqlQuery = Objects.requireNonNull(sqlQuery);
this.setter = Objects.requireNonNull(setter);
this.mapper = Objects.requireNonNull(mapper);
}
public static QueryStmBuilder of(String sqlQuery, ParamsSetter setter, ResultSetMapper mapper) {
return new QueryStmBuilder<>(sqlQuery, setter, mapper);
}
public QueryStmBuilder withFetchSize(int fetchSize) {
if (fetchSize <= 0) throw new IllegalArgumentException("fetchSize <=0");
this.fetchSize = fetchSize;
return this;
}
public QueryStmBuilder withoutRecordedEvents() {
this.enableJFR = false;
return this;
}
@Override
public QueryStm get() {
return new QueryStm<>(sqlQuery, setter, mapper, fetchSize, enableJFR);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy