V - the type of the API Valuepublic class QueryBuilder<V> extends Object implements QueryBuilderInterface<V>
QueryBuilder allows for queries to be constructed in parts.| Modifier and Type | Field and Description | 
|---|---|
protected String | 
from  | 
protected static String | 
FROM  | 
protected Integer | 
limit  | 
protected static String | 
LIMIT  | 
protected Integer | 
offset  | 
protected static String | 
OFFSET  | 
protected static String | 
ORDER_BY  | 
protected String | 
orderBy  | 
protected String | 
select  | 
protected static String | 
SELECT  | 
protected Map<String,V> | 
valueMap  | 
protected String | 
where  | 
protected static String | 
WHERE  | 
| Constructor and Description | 
|---|
QueryBuilder()
Constructs a query builder. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
String | 
buildQuery()
Builds the query from the clauses. 
 | 
QueryBuilder<V> | 
from(String table)
Sets the statement FROM clause in the form of "table". 
 | 
Map<String,V> | 
getBindVariableMap()
Returns an unmodifiable form of the key to value map. 
 | 
Integer | 
getOffset()
Gets the current offset. 
 | 
QueryBuilder<V> | 
increaseOffsetBy(Integer amount)
Increases the offset by the  
amount. | 
QueryBuilder<V> | 
limit(Integer count)
Sets the statement LIMIT clause in the form of 
"LIMIT <count>"
 e.g.  | 
QueryBuilder<V> | 
offset(Integer count)
Sets the statement OFFSET clause in the form of 
"OFFSET <count>"
 e.g.  | 
QueryBuilder<V> | 
orderBy(String orderBy)
Sets the statement ORDER BY clause in the form of 
"ORDER BY <property> [ASC | DESC]"
 e.g.  | 
QueryBuilder<V> | 
removeLimitAndOffset()
Removes the limit and offset from the query. 
 | 
QueryBuilder<V> | 
select(String columns)
Sets the statement SELECT clause in the form of "a,b" or "*". 
 | 
protected void | 
validateQuery()
Checks that the query is valid. 
 | 
QueryBuilder<V> | 
where(String conditions)
Sets the statement WHERE clause in the form of 
"WHERE <condition> {[AND | OR] <condition> ...}"
 e.g.  | 
QueryBuilder<V> | 
withBindVariableValue(String key,
                     V value)
Adds a value to the statement in the form of a  
Value. | 
QueryBuilder<V> | 
withBindVariableValues(Map<String,V> values)
Adds all key value mappings. 
 | 
protected static final String SELECT
protected static final String FROM
protected static final String WHERE
protected static final String LIMIT
protected static final String OFFSET
protected static final String ORDER_BY
protected String select
protected String from
protected String where
protected Integer limit
protected Integer offset
protected String orderBy
public QueryBuilder<V> select(String columns)
PublisherQueryLanguageService. The "SELECT " keyword will be
 ignored.select in interface QueryBuilderInterface<V>columns - the statement select clause without "SELECT"public QueryBuilder<V> from(String table)
PublisherQueryLanguageService. The "FROM " keyword will be
 ignored.from in interface QueryBuilderInterface<V>table - the statement from clause without "FROM"public QueryBuilder<V> where(String conditions)
"WHERE <condition> {[AND | OR] <condition> ...}"
 where in interface QueryBuilderInterface<V>conditions - the statement query without "WHERE"public QueryBuilder<V> limit(Integer count)
"LIMIT <count>"
 limit in interface QueryBuilderInterface<V>count - the statement limitpublic QueryBuilder<V> offset(Integer count)
"OFFSET <count>"
 offset in interface QueryBuilderInterface<V>count - the statement offsetpublic QueryBuilder<V> increaseOffsetBy(Integer amount)
amount.increaseOffsetBy in interface QueryBuilderInterface<V>amount - the amount to increase the offsetpublic Integer getOffset()
getOffset in interface QueryBuilderInterface<V>public QueryBuilder<V> removeLimitAndOffset()
removeLimitAndOffset in interface QueryBuilderInterface<V>public QueryBuilder<V> orderBy(String orderBy)
"ORDER BY <property> [ASC | DESC]"
 orderBy in interface QueryBuilderInterface<V>orderBy - the statement order by without "ORDER BY"public QueryBuilder<V> withBindVariableValue(String key, V value)
Value.withBindVariableValue in interface QueryBuilderInterface<V>key - the value keyvalue - the valuepublic QueryBuilder<V> withBindVariableValues(Map<String,V> values)
values - the mappings of key to value of type public Map<String,V> getBindVariableMap()
getBindVariableMap in interface QueryBuilderInterface<V>protected void validateQuery()
public String buildQuery()
buildQuery in interface QueryBuilderInterface<V>Copyright © 2020. All Rights Reserved.