Class EntityQueryUtils
java.lang.Object
com.foreach.across.modules.entity.query.EntityQueryUtils
- Since:
- 2.2.0
- Author:
- Steven Gentens
-
Method Summary
Modifier and TypeMethodDescriptionstatic EntityQuery
and
(EntityQuery existing, Object predicate) Appends an optional predicate to an existing query using an AND operand.static EntityQuery
appendToQuery
(EntityQuery existing, EntityQueryOps operand, Object predicate) Appends an optional predicate to an existing query using the specified operand.static EntityQueryCondition
createAssociationPredicate
(@NonNull EntityAssociation association, @NonNull Object parent) Create the predicate for fetching entities associated to a specific parent entity, mapped by anEntityAssociation
.static List<EntityQueryCondition>
findConditionsForProperty
(@NonNull EntityQuery entityQuery, @NonNull String propertyName) Finds allEntityQueryCondition
conditions inside anEntityQuery
static EntityQuery
or
(EntityQuery existing, Object predicate) Appends an optional predicate to an existing query using an OR operand.static EntityQuery
simplify
(@NonNull EntityQuery query) Simplifies a query by removing useless levels (grouping of predicates).static EntityQuery
translateConditions
(@NonNull EntityQuery query, @NonNull Function<EntityQueryCondition, EntityQueryExpression> translator, String... properties) Perform simple condition translation on anEntityQuery
, for example to remove conditions.
-
Method Details
-
and
Appends an optional predicate to an existing query using an AND operand. If the predicate is not anEntityQueryExpression
then it will be parsed as an EQL statement.- Parameters:
existing
- query to append topredicate
- to append- Returns:
- new query instance
-
or
Appends an optional predicate to an existing query using an OR operand. If the predicate is not anEntityQueryExpression
then it will be parsed as an EQL statement.- Parameters:
existing
- query to append topredicate
- to append- Returns:
- new query instance
-
appendToQuery
public static EntityQuery appendToQuery(EntityQuery existing, EntityQueryOps operand, Object predicate) Appends an optional predicate to an existing query using the specified operand. If the predicate is not anEntityQueryExpression
then it will be parsed as an EQL statement.- Parameters:
existing
- query to append tooperand
- operand to usepredicate
- to append- Returns:
- new query instance
-
translateConditions
public static EntityQuery translateConditions(@NonNull @NonNull EntityQuery query, @NonNull @NonNull Function<EntityQueryCondition, EntityQueryExpression> translator, String... properties) Perform simple condition translation on anEntityQuery
, for example to remove conditions. For more complex translation scenarios, see theEntityQueryTranslator
implementations. If no properties are specified all conditions will be translated. Else only conditions for the specified properties will be passed to the translator.- Parameters:
query
- to translatetranslator
- function, may returnnull
to remove a condition entirelyproperties
- optional a set of properties whose conditions should be translated, if empty all properties will be passed- Returns:
- new query instance - never
null
-
simplify
Simplifies a query by removing useless levels (grouping of predicates).- Parameters:
query
- to simplify- Returns:
- simplified
-
createAssociationPredicate
public static EntityQueryCondition createAssociationPredicate(@NonNull @NonNull EntityAssociation association, @NonNull @NonNull Object parent) Create the predicate for fetching entities associated to a specific parent entity, mapped by anEntityAssociation
.- Parameters:
association
- entities to fetchparent
- entity they belong to- Returns:
- query predicate
-
findConditionsForProperty
public static List<EntityQueryCondition> findConditionsForProperty(@NonNull @NonNull EntityQuery entityQuery, @NonNull @NonNull String propertyName) Finds allEntityQueryCondition
conditions inside anEntityQuery
- Parameters:
propertyName
- the name of the property in the expression- Returns:
- all
EntityQueryCondition
that match the propertyName
-