Package com.appiancorp.common.query
Class Query.Builder<T>
java.lang.Object
com.appiancorp.common.query.Query.Builder<T>
- All Implemented Interfaces:
QueryBuilder<T>
,QueryBuilder.Aggregating<T>
,QueryBuilder.Filtering<T>
,QueryBuilder.FilteringCriteria<T>
,QueryBuilder.Grouping<T>
,QueryBuilder.Paging<T>
,QueryBuilder.Selecting<T>
,QueryBuilder.Sorting<T>
- Direct Known Subclasses:
GenericQuery.GenericBuilder
,TypedValueQuery.TypedValueBuilder
public abstract static class Query.Builder<T>
extends Object
implements QueryBuilder<T>, QueryBuilder.Selecting<T>, QueryBuilder.Filtering<T>, QueryBuilder.FilteringCriteria<T>, QueryBuilder.Grouping<T>, QueryBuilder.Aggregating<T>, QueryBuilder.Paging<T>, QueryBuilder.Sorting<T>
A class for incrementally build a Query.
The objective of this builder is to help the developer to construct a Query in a more organic way to ease development and avoid invalid configurations.
Each method returns the same Builder instance, but it is bound by interface which the method returns. This way is simulating a flow and the available valid configurations after the current configuration.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.appiancorp.common.query.QueryBuilder
QueryBuilder.Aggregating<T>, QueryBuilder.Filtering<T>, QueryBuilder.FilteringCriteria<T>, QueryBuilder.Grouping<T>, QueryBuilder.Paging<T>, QueryBuilder.Selecting<T>, QueryBuilder.Sorting<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaggregate
(AggregationColumn... a) Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
build()
Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
groupBy
(ColumnAlias... alias) Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
protected abstract LogicalExpression<?>
newLogicalOperation
(LogicalOperator lo, List<Criteria> conditions) Returns aLogicalExpression
instancenewQuerySimplified
(Projection<? extends Column> projection, Criteria criteria, PagingInfo pagingInfo) Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
page
(int startIndex, int batchSize) Obtains the set of operations allowed afterQueryBuilder.Paging<T>
page
(PagingInfo pagingInfo) Defines query'sPagingInfo
Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
select
(ColumnAlias... alias) Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
select
(Collection<String> c) Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
selectFirst
(String column) sortBy
(ReadOnlySortInfo... sortInfos) Defines the query's sorting informationDefines the query's sorting informationsortBy
(com.google.common.collect.ImmutableList<ReadOnlySortInfo> sortInfos) Defines the query's sorting informationDefines the query's sorting information
-
Constructor Details
-
Builder
protected Builder()Initializes a newly createdBuilder
-
Builder
Constructs aBuilder
using the givenQuery
as a base- Parameters:
query
- aQuery
-
-
Method Details
-
newQuerySimplified
protected final Query<T> newQuerySimplified(Projection<? extends Column> projection, Criteria criteria, PagingInfo pagingInfo) -
select
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
select
in interfaceQueryBuilder.Selecting<T>
- Parameters:
c
- the array of column names which the query is going to select- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
select
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
select
in interfaceQueryBuilder.Selecting<T>
- Parameters:
c
- the list of column names which the query is going to select- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
selectFirst
-
select
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
select
in interfaceQueryBuilder.Selecting<T>
- Parameters:
alias
- the array ofColumnAlias
which the query is going to select- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
select
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
select
in interfaceQueryBuilder.Selecting<T>
- Parameters:
c
- the array ofColumn
which the query is going to select- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
select
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
select
in interfaceQueryBuilder.Selecting<T>
- Parameters:
c
- the list ofColumnAlias
which the query is going to select- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
project
Description copied from interface:QueryBuilder.Selecting
Obtains the set of operations allowed afterQueryBuilder.Selecting<T>
- Specified by:
project
in interfaceQueryBuilder.Selecting<T>
- Parameters:
s
- theSelection
to be performed by the query- Returns:
- the
QueryBuilder.Filtering<T>
interface with the set of operations allowed afterQueryBuilder.Selecting<T>
-
criteria
Description copied from interface:QueryBuilder.FilteringCriteria
Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
- Specified by:
criteria
in interfaceQueryBuilder.Filtering<T>
- Specified by:
criteria
in interfaceQueryBuilder.FilteringCriteria<T>
- Parameters:
criteria
- TheCriteria
used to bound the query.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
-
and
Description copied from interface:QueryBuilder.FilteringCriteria
Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
- Specified by:
and
in interfaceQueryBuilder.Filtering<T>
- Specified by:
and
in interfaceQueryBuilder.FilteringCriteria<T>
- Parameters:
criteria
- TheCriteria
that will be combined with the existing Criteria using the AND operator.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.Filtering<T>
-
or
Description copied from interface:QueryBuilder.FilteringCriteria
Obtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>
- Specified by:
or
in interfaceQueryBuilder.Filtering<T>
- Specified by:
or
in interfaceQueryBuilder.FilteringCriteria<T>
- Parameters:
criteria
- TheCriteria
that will be combined with the existing Criteria using the OR operator.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.Filtering<T>
-
groupBy
Description copied from interface:QueryBuilder.Grouping
Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
- Specified by:
groupBy
in interfaceQueryBuilder.Grouping<T>
- Parameters:
c
- the array of column names which the query is going to group by.- Returns:
- the
QueryBuilder.Aggregating<T>
interface with the set of operations allowed afterQueryBuilder.Grouping<T>
-
groupBy
Description copied from interface:QueryBuilder.Grouping
Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
- Specified by:
groupBy
in interfaceQueryBuilder.Grouping<T>
- Parameters:
alias
- the array ofColumnAlias
which the query is going to group by.- Returns:
- the
QueryBuilder.Aggregating<T>
interface with the set of operations allowed afterQueryBuilder.Grouping<T>
-
groupBy
Description copied from interface:QueryBuilder.Grouping
Obtains the set of operations allowed afterQueryBuilder.Grouping<T>
- Specified by:
groupBy
in interfaceQueryBuilder.Grouping<T>
- Parameters:
c
- the array ofColumn
which the query is going to group by.- Returns:
- the
QueryBuilder.Aggregating<T>
interface with the set of operations allowed afterQueryBuilder.Grouping<T>
-
aggregate
Description copied from interface:QueryBuilder.Aggregating
Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
- Specified by:
aggregate
in interfaceQueryBuilder.Aggregating<T>
- Parameters:
a
- the array ofAggregationColumn
where the query is going perform aggregation operations.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.Aggregating<T>
-
aggregate
Description copied from interface:QueryBuilder.Aggregating
Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
- Specified by:
aggregate
in interfaceQueryBuilder.Aggregating<T>
- Parameters:
a
- the list ofAggregationColumn
where the query is going perform aggregation operations.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.Aggregating<T>
-
project
Description copied from interface:QueryBuilder.Aggregating
Obtains the set of operations allowed afterQueryBuilder.Aggregating<T>
- Specified by:
project
in interfaceQueryBuilder.Aggregating<T>
- Parameters:
a
- theAggregation
to be performed by the query.- Returns:
- the
QueryBuilder.Grouping<T>
interface with the set of operations allowed afterQueryBuilder.Aggregating<T>
-
page
Description copied from interface:QueryBuilder.Paging
Obtains the set of operations allowed afterQueryBuilder.Paging<T>
- Specified by:
page
in interfaceQueryBuilder.Paging<T>
batchSize
- the number of results to return in one page. If negative, the full result set should be returned.- Returns:
- the
QueryBuilder.Sorting<T>
interface with the set of operations allowed afterQueryBuilder.Paging<T>
-
page
Description copied from interface:QueryBuilder.Paging
Defines query'sPagingInfo
- Specified by:
page
in interfaceQueryBuilder.Paging<T>
- Parameters:
pagingInfo
- thePagingInfo
describing how to page the results- Returns:
- the
QueryBuilder<T>
which can produce aQuery<T>
instance.
-
sortBy
Description copied from interface:QueryBuilder.Sorting
Defines the query's sorting information- Specified by:
sortBy
in interfaceQueryBuilder.Sorting<T>
- Parameters:
sortInfos
- the array ofSortInfo
which the query is going to use to determine the order of the result data.- Returns:
- the
QueryBuilder<T>
which can produce aQuery<T>
instance.
-
sortBy
Description copied from interface:QueryBuilder.Sorting
Defines the query's sorting information- Specified by:
sortBy
in interfaceQueryBuilder.Sorting<T>
- Parameters:
sortInfos
- the list ofSortInfo
which the query is going to use to determine the order of the result data.- Returns:
- the
QueryBuilder<T>
which can produce aQuery<T>
instance.
-
sortBy
Description copied from interface:QueryBuilder.Sorting
Defines the query's sorting information- Specified by:
sortBy
in interfaceQueryBuilder.Sorting<T>
- Parameters:
sortInfos
- the array ofReadOnlySortInfo
which the query is going to use to determine the order of the result data.- Returns:
- the
QueryBuilder<T>
which can produce aQuery<T>
instance.
-
sortBy
Description copied from interface:QueryBuilder.Sorting
Defines the query's sorting information- Specified by:
sortBy
in interfaceQueryBuilder.Sorting<T>
- Parameters:
sortInfos
- the list ofReadOnlySortInfo
which the query is going to use to determine the order of the result data.- Returns:
- the
QueryBuilder<T>
which can produce aQuery<T>
instance.
-
build
Description copied from interface:QueryBuilder
- Specified by:
build
in interfaceQueryBuilder<T>
- Returns:
- a
Query<T>
instance.
-
newLogicalOperation
protected abstract LogicalExpression<?> newLogicalOperation(LogicalOperator lo, List<Criteria> conditions) Returns aLogicalExpression
instance- Parameters:
lo
- logical operation type represented byLogicalOperator
conditions
-- Returns:
- a
LogicalExpression
instance
-