
jio.jdbc.QueryOneStmBuilder 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.Objects;
import java.util.function.Supplier;
/**
* Builder class for constructing instances of {@link QueryOneStm}, which represents a JDBC query operation returning a
* single result. This builder allows customization of the SQL query, parameter setting, result mapping, and the option
* to disable Java Flight Recorder (JFR) event recording for the query execution.
*
* @param The type of input parameters for the JDBC query.
* @param The type of the output result for the JDBC query.
*/
public final class QueryOneStmBuilder implements Supplier> {
private final String sqlQuery;
private final ParamsSetter setter;
private final ResultSetMapper mapper;
private boolean enableJFR = true;
private QueryOneStmBuilder(String sqlQuery, ParamsSetter setter, ResultSetMapper mapper) {
this.sqlQuery = Objects.requireNonNull(sqlQuery);
this.setter = Objects.requireNonNull(setter);
this.mapper = Objects.requireNonNull(mapper);
}
/**
* Creates a new instance of {@code QueryOneStmBuilder} with the specified SQL query, parameter setter, and result
* mapper.
*
* @param sqlQuery The SQL query string.
* @param setter The parameter setter for the SQL query.
* @param mapper The result mapper for mapping query results.
* @param The type of input parameters for the JDBC query.
* @param The type of the output result for the JDBC query.
* @return A new instance of {@code QueryOneStmBuilder}.
*/
public static QueryOneStmBuilder of(String sqlQuery, ParamsSetter setter, ResultSetMapper mapper) {
return new QueryOneStmBuilder<>(sqlQuery, setter, mapper);
}
/**
* Disables the recording of Java Flight Recorder (JFR) events for the JDBC query execution.
*
* @return This {@code QueryOneStmBuilder} instance with JFR event recording disabled.
*/
public QueryOneStmBuilder withoutRecordedEvents() {
this.enableJFR = false;
return this;
}
/**
* Builds and returns a new instance of {@link QueryOneStm} based on the configured parameters.
*
* @return A new instance of {@code QueryOneStm}.
*/
@Override
public JdbcLambda get() {
return new QueryOneStm<>(sqlQuery, setter, mapper, enableJFR);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy