Class QueryConstraints


  • public class QueryConstraints
    extends java.lang.Object
    A class which administers default query constraints set for entities.
    Author:
    Collin Alpert
    • Method Summary

      Modifier and Type Method Description
      static <E extends BaseEntity>
      void
      addConstraint​(java.lang.Class<E> clazz, com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> predicate)
      Adds a query constraint to a query made with a certain entity.
      static <E extends BaseEntity>
      com.github.collinalpert.lambda2sql.functions.SqlPredicate<E>
      getConstraints​(java.lang.Class<E> clazz)
      Retrieves a composition SqlPredicate for all constraints that have been added for a class or any superclass of it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryConstraints

        public QueryConstraints()
    • Method Detail

      • getConstraints

        public static <E extends BaseEntity> com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> getConstraints​(java.lang.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​(java.lang.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.