Class EntityQueryUtils

java.lang.Object
com.foreach.across.modules.entity.query.EntityQueryUtils

public abstract class EntityQueryUtils extends Object
Since:
2.2.0
Author:
Steven Gentens
  • Method Details

    • and

      public static EntityQuery and(EntityQuery existing, Object predicate)
      Appends an optional predicate to an existing query using an AND operand. If the predicate is not an EntityQueryExpression then it will be parsed as an EQL statement.
      Parameters:
      existing - query to append to
      predicate - to append
      Returns:
      new query instance
    • or

      public static EntityQuery or(EntityQuery existing, Object predicate)
      Appends an optional predicate to an existing query using an OR operand. If the predicate is not an EntityQueryExpression then it will be parsed as an EQL statement.
      Parameters:
      existing - query to append to
      predicate - 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 an EntityQueryExpression then it will be parsed as an EQL statement.
      Parameters:
      existing - query to append to
      operand - operand to use
      predicate - 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 an EntityQuery, for example to remove conditions. For more complex translation scenarios, see the EntityQueryTranslator 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 translate
      translator - function, may return null to remove a condition entirely
      properties - optional a set of properties whose conditions should be translated, if empty all properties will be passed
      Returns:
      new query instance - never null
    • simplify

      public static EntityQuery simplify(@NonNull @NonNull EntityQuery query)
      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 an EntityAssociation.
      Parameters:
      association - entities to fetch
      parent - entity they belong to
      Returns:
      query predicate
    • findConditionsForProperty

      public static List<EntityQueryCondition> findConditionsForProperty(@NonNull @NonNull EntityQuery entityQuery, @NonNull @NonNull String propertyName)
      Finds all EntityQueryCondition conditions inside an EntityQuery
      Parameters:
      propertyName - the name of the property in the expression
      Returns:
      all EntityQueryCondition that match the propertyName