Class EntityQuery
java.lang.Object
com.foreach.across.modules.entity.query.EntityQuery
- All Implemented Interfaces:
EntityQueryExpression
Abstraction layer for *simple* query construction. An EntityQuery is a simple structure that has the support classes
to be constructed from maps, de-serialized to and from JSON and later converted to specific query structures like
JPA or QueryDSL.
An EntityQuery is limited in what it supports because it provides a common denominator for different query types.
- Author:
- Arne Vandamme
- See Also:
-
Constructor Summary
ConstructorDescriptionEntityQuery
(@NonNull EntityQueryOps operand) EntityQuery
(EntityQuery entityQuery) -
Method Summary
Modifier and TypeMethodDescriptionfinal EntityQuery
add
(EntityQueryExpression expression) static EntityQuery
all()
static EntityQuery
all
(org.springframework.data.domain.Sort sort) static EntityQuery
and
(EntityQueryExpression... expressions) Merges one or more entity queries expressions together usingEntityQueryOps.AND
.static EntityQuery
create
(EntityQueryOps operand, EntityQueryExpression... expressions) boolean
@NonNull List<EntityQueryExpression>
org.springframework.data.domain.Sort
getSort()
Ordering of the results.boolean
int
hashCode()
boolean
hasSort()
boolean
If an expression is marked as translated no additional translation should be performed by anEntityQueryTranslator
.static EntityQuery
of
(EntityQuery query) Create a duplicate of an existing query.static EntityQuery
static EntityQuery
or
(EntityQueryExpression... expressions) Merges one or more entity queries expressions together usingEntityQueryOps.OR
.static EntityQuery
Converts an EQL statement into a (raw)EntityQuery
.setExpressions
(@NonNull List<EntityQueryExpression> expressions) setOperand
(@NonNull EntityQueryOps operand) setSort
(org.springframework.data.domain.Sort sort) Ordering of the results.setTranslated
(boolean translated) toString()
-
Constructor Details
-
EntityQuery
public EntityQuery() -
EntityQuery
-
EntityQuery
-
-
Method Details
-
add
-
setOperand
-
equals
-
hashCode
public int hashCode() -
toString
-
hasExpressions
public boolean hasExpressions()- Returns:
- true if one or more expressions are present
-
hasSort
public boolean hasSort()- Returns:
- true if a sort has been set on this query and it contains orders
-
all
- Returns:
- new EntityQuery instance that will return all entities.
-
all
- Returns:
- new EntityQuery instance that will return all entities, sorted accordingly
-
parse
Converts an EQL statement into a (raw)EntityQuery
. Not validation or translation of any kind will be done on the elements, this will simply convert theString
tokens into anEntityQuery
object. You should useEntityQueryParser.parse(String)
of the relevant entity if you want to parse an EQL into a fully executableEntityQuery
. You can useEntityQueryParser.prepare(EntityQuery)
to convert the raw query object into an executable one. Exceptions will be thrown if parsing fails.- Parameters:
eql
- to convert- Returns:
- EntityQuery
-
and
Merges one or more entity queries expressions together usingEntityQueryOps.AND
. If expressions are sub-queries that define sort values, only the first non-null sort value will be kept. This method is null safe:null
values will simply be ignored and a query will always be returned.- Parameters:
expressions
- to merge- Returns:
- merged query
-
or
Merges one or more entity queries expressions together usingEntityQueryOps.OR
. If expressions are sub-queries that define sort values, only the first non-null sort value will be kept. This method is null safe:null
values will simply be ignored and a query will always be returned.- Parameters:
expressions
- to merge- Returns:
- merged query
-
create
-
of
- Parameters:
eql
- eql statement- Returns:
- entity query
- See Also:
-
of
Create a duplicate of an existing query. If the value passed in isnull
, a query instance for all values will be returned. As such, this method can be used to return the default query if you have a null value.- Parameters:
query
- to duplicate- Returns:
- query - never null
-
getSort
public org.springframework.data.domain.Sort getSort()Ordering of the results. -
getOperand
- Specified by:
getOperand
in interfaceEntityQueryExpression
-
getExpressions
-
isTranslated
public boolean isTranslated()Description copied from interface:EntityQueryExpression
If an expression is marked as translated no additional translation should be performed by anEntityQueryTranslator
.- Specified by:
isTranslated
in interfaceEntityQueryExpression
- Returns:
- true if this expression is marked as translated.
- See Also:
-
setSort
Ordering of the results.- Returns:
this
.
-
setExpressions
- Returns:
this
.
-
setTranslated
- Returns:
this
.
-