@Test public void testBuildQuery_empty() { String expectedQuery = ""; String query = new QueryBuilder<Object>() .buildQuery(); assertEquals(expectedQuery, query); }
@Override public String buildQuery() { validateQuery(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(select)) { stringBuilder = stringBuilder.append(SELECT).append(" ").append(select).append(" "); } if (!Strings.isNullOrEmpty(from)) { stringBuilder = stringBuilder.append(FROM).append(" ").append(from).append(" "); } if (!Strings.isNullOrEmpty(where)) { stringBuilder = stringBuilder.append(WHERE).append(" ").append(where).append(" "); } if (!Strings.isNullOrEmpty(orderBy)) { stringBuilder = stringBuilder.append(ORDER_BY).append(" ").append(orderBy).append(" "); } if (limit != null) { stringBuilder = stringBuilder.append(LIMIT).append(" ").append(limit).append(" "); } if (offset != null) { stringBuilder = stringBuilder.append(OFFSET).append(" ").append(offset).append(" "); } return stringBuilder.toString().trim(); }
QueryBuilder implements QueryBuilderInterface<V> { @Override public String buildQuery() { validateQuery(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(select)) { stringBuilder = stringBuilder.append(SELECT).append(" ").append(select).append(" "); } if (!Strings.isNullOrEmpty(from)) { stringBuilder = stringBuilder.append(FROM).append(" ").append(from).append(" "); } if (!Strings.isNullOrEmpty(where)) { stringBuilder = stringBuilder.append(WHERE).append(" ").append(where).append(" "); } if (!Strings.isNullOrEmpty(orderBy)) { stringBuilder = stringBuilder.append(ORDER_BY).append(" ").append(orderBy).append(" "); } if (limit != null) { stringBuilder = stringBuilder.append(LIMIT).append(" ").append(limit).append(" "); } if (offset != null) { stringBuilder = stringBuilder.append(OFFSET).append(" ").append(offset).append(" "); } return stringBuilder.toString().trim(); } }
QueryBuilder implements QueryBuilderInterface<V> { @Override public String buildQuery() { validateQuery(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(select)) { stringBuilder = stringBuilder.append(SELECT).append(" ").append(select).append(" "); } if (!Strings.isNullOrEmpty(from)) { stringBuilder = stringBuilder.append(FROM).append(" ").append(from).append(" "); } if (!Strings.isNullOrEmpty(where)) { stringBuilder = stringBuilder.append(WHERE).append(" ").append(where).append(" "); } if (!Strings.isNullOrEmpty(orderBy)) { stringBuilder = stringBuilder.append(ORDER_BY).append(" ").append(orderBy).append(" "); } if (limit != null) { stringBuilder = stringBuilder.append(LIMIT).append(" ").append(limit).append(" "); } if (offset != null) { stringBuilder = stringBuilder.append(OFFSET).append(" ").append(offset).append(" "); } return stringBuilder.toString().trim(); } QueryBuilder(); }
QueryBuilder implements QueryBuilderInterface<V> { @Override public String buildQuery() { validateQuery(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(select)) { stringBuilder = stringBuilder.append(SELECT).append(" ").append(select).append(" "); } if (!Strings.isNullOrEmpty(from)) { stringBuilder = stringBuilder.append(FROM).append(" ").append(from).append(" "); } if (!Strings.isNullOrEmpty(where)) { stringBuilder = stringBuilder.append(WHERE).append(" ").append(where).append(" "); } if (!Strings.isNullOrEmpty(orderBy)) { stringBuilder = stringBuilder.append(ORDER_BY).append(" ").append(orderBy).append(" "); } if (limit != null) { stringBuilder = stringBuilder.append(LIMIT).append(" ").append(limit).append(" "); } if (offset != null) { stringBuilder = stringBuilder.append(OFFSET).append(" ").append(offset).append(" "); } return stringBuilder.toString().trim(); } QueryBuilder(); @Override QueryBuilder<V> select(String columns); @Override QueryBuilder<V> from(String table); @Override QueryBuilder<V> where(String conditions); @Override QueryBuilder<V> limit(Integer count); @Override QueryBuilder<V> offset(Integer count); @Override QueryBuilder<V> increaseOffsetBy(Integer amount); @Override Integer getOffset(); @Override QueryBuilder<V> removeLimitAndOffset(); @Override QueryBuilder<V> orderBy(String orderBy); @Override QueryBuilder<V> withBindVariableValue(String key, V value); QueryBuilder<V> withBindVariableValues(Map<String, V> values); @Override Map<String, V> getBindVariableMap(); @Override String buildQuery(); }
QueryBuilder implements QueryBuilderInterface<V> { @Override public String buildQuery() { validateQuery(); StringBuilder stringBuilder = new StringBuilder(); if (!Strings.isNullOrEmpty(select)) { stringBuilder = stringBuilder.append(SELECT).append(" ").append(select).append(" "); } if (!Strings.isNullOrEmpty(from)) { stringBuilder = stringBuilder.append(FROM).append(" ").append(from).append(" "); } if (!Strings.isNullOrEmpty(where)) { stringBuilder = stringBuilder.append(WHERE).append(" ").append(where).append(" "); } if (!Strings.isNullOrEmpty(orderBy)) { stringBuilder = stringBuilder.append(ORDER_BY).append(" ").append(orderBy).append(" "); } if (limit != null) { stringBuilder = stringBuilder.append(LIMIT).append(" ").append(limit).append(" "); } if (offset != null) { stringBuilder = stringBuilder.append(OFFSET).append(" ").append(offset).append(" "); } return stringBuilder.toString().trim(); } QueryBuilder(); @Override QueryBuilder<V> select(String columns); @Override QueryBuilder<V> from(String table); @Override QueryBuilder<V> where(String conditions); @Override QueryBuilder<V> limit(Integer count); @Override QueryBuilder<V> offset(Integer count); @Override QueryBuilder<V> increaseOffsetBy(Integer amount); @Override Integer getOffset(); @Override QueryBuilder<V> removeLimitAndOffset(); @Override QueryBuilder<V> orderBy(String orderBy); @Override QueryBuilder<V> withBindVariableValue(String key, V value); QueryBuilder<V> withBindVariableValues(Map<String, V> values); @Override Map<String, V> getBindVariableMap(); @Override String buildQuery();  }