Class QueryConstraints
java.lang.Object
com.github.collinalpert.java2db.queries.QueryConstraints
public class QueryConstraints
extends java.lang.Object
A class which administers default query constraints set for entities.
- Author:
- Collin Alpert
-
Constructor Summary
Constructors Constructor Description QueryConstraints() -
Method Summary
Modifier and Type Method Description static <E extends BaseEntity>
voidaddConstraint(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 compositionSqlPredicatefor all constraints that have been added for a class or any superclass of it.static voidremoveConstraints(java.lang.Class<? extends BaseEntity> clazz)Removes all query constraints which were set for a specific entity.
-
Constructor Details
-
QueryConstraints
public QueryConstraints()
-
-
Method Details
-
getConstraints
public static <E extends BaseEntity> com.github.collinalpert.lambda2sql.functions.SqlPredicate<E> getConstraints(java.lang.Class<E> clazz)Retrieves a compositionSqlPredicatefor 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
SqlPredicatedescribing 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 thispredicate.- Type Parameters:
E- The type of the entity.- Parameters:
clazz- The entity to add the constraint to.predicate- The constraint.
-
removeConstraints
Removes all query constraints which were set for a specific entity.- Parameters:
clazz- The entity class to remove the constraints for.
-