Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class QueryWhereBuilder<T,U> {
private final Map<String, Object> whereTerms = new HashMap<>();
private final QueryBuilder<T, U> qb;
public QueryWhereBuilder(QueryBuilder<T,U> qb) {
this.qb = qb;
public void add(String key, Object val) {
whereTerms.put(key, val);
public void build() throws SQLException {
if (whereTerms.isEmpty()) {
Where<T, U> where = qb.where();
boolean first = true;
for (final String key : whereTerms.keySet()) {
if (!first) {
where.eq(key, whereTerms.get(key));
first = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment