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
ConstructorsConstructorDescriptionEntityQuery(@NonNull EntityQueryOps operand) EntityQuery(EntityQuery entityQuery) -
Method Summary
Modifier and TypeMethodDescriptionfinal EntityQueryadd(EntityQueryExpression expression) static EntityQueryall()static EntityQueryall(org.springframework.data.domain.Sort sort) static EntityQueryand(EntityQueryExpression... expressions) Merges one or more entity queries expressions together usingEntityQueryOps.AND.static EntityQuerycreate(EntityQueryOps operand, EntityQueryExpression... expressions) boolean@NonNull List<EntityQueryExpression>org.springframework.data.domain.SortgetSort()Ordering of the results.booleaninthashCode()booleanhasSort()booleanIf an expression is marked as translated no additional translation should be performed by anEntityQueryTranslator.static EntityQueryof(EntityQuery query) Create a duplicate of an existing query.static EntityQuerystatic EntityQueryor(EntityQueryExpression... expressions) Merges one or more entity queries expressions together usingEntityQueryOps.OR.static EntityQueryConverts 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 theStringtokens into anEntityQueryobject. 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:nullvalues 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:nullvalues 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:
getOperandin interfaceEntityQueryExpression
-
getExpressions
-
isTranslated
public boolean isTranslated()Description copied from interface:EntityQueryExpressionIf an expression is marked as translated no additional translation should be performed by anEntityQueryTranslator.- Specified by:
isTranslatedin 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.
-