Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yonilevy
Created June 20, 2016 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonilevy/1ff55f776bc7fb81ebdddb91a8269926 to your computer and use it in GitHub Desktop.
Save yonilevy/1ff55f776bc7fb81ebdddb91a8269926 to your computer and use it in GitHub Desktop.
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()) {
return;
}
Where<T, U> where = qb.where();
boolean first = true;
for (final String key : whereTerms.keySet()) {
if (!first) {
where.and();
}
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