Package com.codingchili.core.storage
Class Query<Value extends Storable>
java.lang.Object
com.codingchili.core.storage.Query<Value>
- All Implemented Interfaces:
QueryBuilder<Value>
Provides the ability to create a query without an existing storage.
Can be used to create reusable queries and string based/serializable queries.
If the query is to be executed the #must be set or an exception will be thrown.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a new AND clause to the query.Matches documents with the attribute between and including minimum and maximum.equalTo(Comparable match)
Matches if the attribute is an exact match to the given text.void
execute(io.vertx.core.Handler<io.vertx.core.AsyncResult<Collection<Value>>> handler)
Executes the constructed query asynchronously.in(Comparable... list)
Matches if a specified attribute is contained within the given listMatches documents where the attribute containst the given textSets a mapping function that can be used to intercept results.Checks if the given attribute matches the given regex.name()
Generates unique ids for the triggers that are used.The attribute to be queried.Adds a new OR clause to the query.Orders the result by the given direction using the last specified attribute handler unless orderBy is set.Orders the result by the given attribute using the default sort order unless the sort order has been explicitly set.page(int page)
set the page offset for paging support.pageSize(int pageSize)
set the size of each page for paging support.poll(Consumer<Collection<Value>> consumer, TimerSource timer)
Executes the query periodically.Sets a name for the query for identification.startsWith(String text)
Matches if the specified attribute starts with the given textstorage(AsyncStorage<Value> storage)
If intending to invoke either #execute(Handler)
or #poll(Consumer, TimerSource)
this method must be called first.toString()
-
Field Details
-
ON
- See Also:
- Constant Field Values
-
AND
- See Also:
- Constant Field Values
-
OR
- See Also:
- Constant Field Values
-
PAGE
- See Also:
- Constant Field Values
-
PAGESIZE
- See Also:
- Constant Field Values
-
BETWEEN
- See Also:
- Constant Field Values
-
LIKE
- See Also:
- Constant Field Values
-
STARTSWITH
- See Also:
- Constant Field Values
-
IN
- See Also:
- Constant Field Values
-
EQ
- See Also:
- Constant Field Values
-
ORDERBY
- See Also:
- Constant Field Values
-
REGEX
- See Also:
- Constant Field Values
-
QUERY
- See Also:
- Constant Field Values
-
NAMED
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Query
public Query()
-
-
Method Details
-
and
Description copied from interface:QueryBuilder
Adds a new AND clause to the query.- Specified by:
and
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
attribute
- the name of the attribute to be queried.- Returns:
- fluent
-
or
Description copied from interface:QueryBuilder
Adds a new OR clause to the query.- Specified by:
or
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
attribute
- the name of the attribute to be queried.- Returns:
- fluent
-
on
Description copied from interface:QueryBuilder
The attribute to be queried.- Specified by:
on
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
attribute
- the name of the queried attribute.- Returns:
- fluent
-
page
Description copied from interface:QueryBuilder
set the page offset for paging support.- Specified by:
page
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
page
- the page to return results from.- Returns:
- fluent
-
pageSize
Description copied from interface:QueryBuilder
set the size of each page for paging support.- Specified by:
pageSize
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
pageSize
- the number of hits returned on each page.- Returns:
- fluent
-
between
Description copied from interface:QueryBuilder
Matches documents with the attribute between and including minimum and maximum.- Specified by:
between
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
minimum
- the minimum value to matchmaximum
- the maximum value to match- Returns:
- fluent
-
like
Description copied from interface:QueryBuilder
Matches documents where the attribute containst the given text- Specified by:
like
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
text
- the text to check if contained.- Returns:
- fluent
-
startsWith
Description copied from interface:QueryBuilder
Matches if the specified attribute starts with the given text- Specified by:
startsWith
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
text
- the text to check if starting with.- Returns:
- fluent
-
in
Description copied from interface:QueryBuilder
Matches if a specified attribute is contained within the given list- Specified by:
in
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
list
- the list that the attribute value must be contained in to match.- Returns:
- fluent
-
equalTo
Description copied from interface:QueryBuilder
Matches if the attribute is an exact match to the given text.- Specified by:
equalTo
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
match
- the text that should be equal to the specified attribute.- Returns:
- fluent
-
matches
Description copied from interface:QueryBuilder
Checks if the given attribute matches the given regex. Be careful when passing user input to this method. No complexity restrictions are applied. To pass user input use equals instead. If a query can use any non-regex constraint, it is recommended to use that instead.- Specified by:
matches
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
regex
- the regular expression in which the attribute is to match- Returns:
- fluent
-
orderBy
Description copied from interface:QueryBuilder
Orders the result by the given attribute using the default sort order unless the sort order has been explicitly set.- Specified by:
orderBy
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
orderByAttribute
- the handler of the attribute to sort by using dot notation.- Returns:
- fluent
-
order
Description copied from interface:QueryBuilder
Orders the result by the given direction using the last specified attribute handler unless orderBy is set.- Specified by:
order
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
order
- descending or ascending.- Returns:
- fluent
-
storage
If intending to invoke either #execute(Handler)
or #poll(Consumer, TimerSource)
this method must be called first.- Parameters:
storage
- the storage to use if the standalone query is executed.- Returns:
- fluent.
-
execute
Description copied from interface:QueryBuilder
Executes the constructed query asynchronously.- Specified by:
execute
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
handler
- the handler to be invoked when the result is completed.
-
mapper
Sets a mapping function that can be used to intercept results.- Parameters:
mapper
- a mapper that is called for each result when the query is executed.- Returns:
- fluent.
-
poll
Description copied from interface:QueryBuilder
Executes the query periodically.- Specified by:
poll
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
consumer
- a consumer that receives the resultstimer
- the source of the interval.- Returns:
- fluent.
-
name
Description copied from interface:QueryBuilder
Generates unique ids for the triggers that are used. Should be overridden so that logging messages are a bit meaningful.- Specified by:
name
in interfaceQueryBuilder<Value extends Storable>
- Returns:
- a name that identifies this query.
-
setName
Description copied from interface:QueryBuilder
Sets a name for the query for identification.- Specified by:
setName
in interfaceQueryBuilder<Value extends Storable>
- Parameters:
name
- the name to set- Returns:
- fluent
-
toString
-