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
Constructors -
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 aLogicalExpressioninstancenewQuerySimplified(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'sPagingInfoObtains 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 aBuilderusing the givenQueryas 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
selectin 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
selectin 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
selectin interfaceQueryBuilder.Selecting<T>- Parameters:
alias- the array ofColumnAliaswhich 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
selectin interfaceQueryBuilder.Selecting<T>- Parameters:
c- the array ofColumnwhich 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
selectin interfaceQueryBuilder.Selecting<T>- Parameters:
c- the list ofColumnAliaswhich 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.SelectingObtains the set of operations allowed afterQueryBuilder.Selecting<T>- Specified by:
projectin interfaceQueryBuilder.Selecting<T>- Parameters:
s- theSelectionto 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.FilteringCriteriaObtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>- Specified by:
criteriain interfaceQueryBuilder.Filtering<T>- Specified by:
criteriain interfaceQueryBuilder.FilteringCriteria<T>- Parameters:
criteria- TheCriteriaused 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.FilteringCriteriaObtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>- Specified by:
andin interfaceQueryBuilder.Filtering<T>- Specified by:
andin interfaceQueryBuilder.FilteringCriteria<T>- Parameters:
criteria- TheCriteriathat 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.FilteringCriteriaObtains the set of operations allowed afterQueryBuilder.FilteringCriteria<T>- Specified by:
orin interfaceQueryBuilder.Filtering<T>- Specified by:
orin interfaceQueryBuilder.FilteringCriteria<T>- Parameters:
criteria- TheCriteriathat 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.GroupingObtains the set of operations allowed afterQueryBuilder.Grouping<T>- Specified by:
groupByin 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.GroupingObtains the set of operations allowed afterQueryBuilder.Grouping<T>- Specified by:
groupByin interfaceQueryBuilder.Grouping<T>- Parameters:
alias- the array ofColumnAliaswhich 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.GroupingObtains the set of operations allowed afterQueryBuilder.Grouping<T>- Specified by:
groupByin interfaceQueryBuilder.Grouping<T>- Parameters:
c- the array ofColumnwhich 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.AggregatingObtains the set of operations allowed afterQueryBuilder.Aggregating<T>- Specified by:
aggregatein interfaceQueryBuilder.Aggregating<T>- Parameters:
a- the array ofAggregationColumnwhere 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.AggregatingObtains the set of operations allowed afterQueryBuilder.Aggregating<T>- Specified by:
aggregatein interfaceQueryBuilder.Aggregating<T>- Parameters:
a- the list ofAggregationColumnwhere 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.AggregatingObtains the set of operations allowed afterQueryBuilder.Aggregating<T>- Specified by:
projectin interfaceQueryBuilder.Aggregating<T>- Parameters:
a- theAggregationto 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.PagingObtains the set of operations allowed afterQueryBuilder.Paging<T>- Specified by:
pagein 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.PagingDefines query'sPagingInfo- Specified by:
pagein interfaceQueryBuilder.Paging<T>- Parameters:
pagingInfo- thePagingInfodescribing how to page the results- Returns:
- the
QueryBuilder<T>which can produce aQuery<T>instance.
-
sortBy
Description copied from interface:QueryBuilder.SortingDefines the query's sorting information- Specified by:
sortByin interfaceQueryBuilder.Sorting<T>- Parameters:
sortInfos- the array ofSortInfowhich 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.SortingDefines the query's sorting information- Specified by:
sortByin interfaceQueryBuilder.Sorting<T>- Parameters:
sortInfos- the list ofSortInfowhich 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.SortingDefines the query's sorting information- Specified by:
sortByin interfaceQueryBuilder.Sorting<T>- Parameters:
sortInfos- the array ofReadOnlySortInfowhich 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.SortingDefines the query's sorting information- Specified by:
sortByin interfaceQueryBuilder.Sorting<T>- Parameters:
sortInfos- the list ofReadOnlySortInfowhich 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:
buildin interfaceQueryBuilder<T>- Returns:
- a
Query<T>instance.
-
newLogicalOperation
protected abstract LogicalExpression<?> newLogicalOperation(LogicalOperator lo, List<Criteria> conditions) Returns aLogicalExpressioninstance- Parameters:
lo- logical operation type represented byLogicalOperatorconditions-- Returns:
- a
LogicalExpressioninstance
-