@Test public void testFilterQueryBuilder() { DatabaseQueryBuilder actual = new DatabaseQueryBuilder(SELECT); assertNotNull(actual); assertNotNull(actual.getSQL()); assertEquals(SELECT, actual.getSQL()); }
public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; }
DatabaseQueryBuilder { public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; } }
DatabaseQueryBuilder { public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; } DatabaseQueryBuilder(String tableName, Set<String> columns);  DatabaseQueryBuilder(final String selectFrom); }
DatabaseQueryBuilder { public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; } DatabaseQueryBuilder(String tableName, Set<String> columns);  DatabaseQueryBuilder(final String selectFrom); void setColumns(Set<String> columns); void setSelectFrom(String selectFrom); void setTableName(String tableName); void setWhere(FilterWhereBuilder whereBuilder); void setOrderBy(List<OrderBy> orderBy); String getSQL(); List<SQLParam> getParams(); }
DatabaseQueryBuilder { public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; } DatabaseQueryBuilder(String tableName, Set<String> columns);  DatabaseQueryBuilder(final String selectFrom); void setColumns(Set<String> columns); void setSelectFrom(String selectFrom); void setTableName(String tableName); void setWhere(FilterWhereBuilder whereBuilder); void setOrderBy(List<OrderBy> orderBy); String getSQL(); List<SQLParam> getParams();  }