Class QueryConstraints


  • public class QueryConstraints
    extends Object
    A class which administers default query constraints set for entities.
    Author:
    Collin Alpert
    • Constructor Detail

      • QueryConstraints

        public QueryConstraints()
    • Method Detail

      • getConstraints

        public static <E extends BaseEntity> com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> getConstraints​(Class<E> clazz)
        Retrieves a composition SqlPredicate for all constraints that have been added for a class or any superclass of it.
        Type Parameters:
        E - The type of the class to get the constraints for.
        Parameters:
        clazz - The class to retrieve query constraints from.
        Returns:
        A SqlPredicate describing the added constraints.
      • addConstraint

        public static <E extends BaseEntity> void addConstraint​(Class<E> clazz,
                                                                com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)
        Adds a query constraint to a query made with a certain entity. This means that any query made with this entity will include this predicate.
        Type Parameters:
        E - The type of the entity.
        Parameters:
        clazz - The entity to add the constraint to.
        predicate - The constraint.
      • removeConstraints

        public static void removeConstraints​(Class<? extends BaseEntity> clazz)
        Removes all query constraints which were set for a specific entity.
        Parameters:
        clazz - The entity class to remove the constraints for.