com.h3c.util.dao

## Class QueryPredicateGenerator<P extends Storable<?>>

- java.lang.Object
- - com.h3c.util.dao.QueryPredicateGenerator<P>

- Type Parameters:
    `P` - type of model persistent object.

      public class QueryPredicateGenerator<P extends Storable<?>>
      extends Object

  Query predicate generator.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryPredicateGenerator()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `javax.persistence.criteria.Predicate` | `and(javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Predicate... predicates)` Performs And operation on the given predicates.
    `<D extends Comparable<D>> javax.persistence.criteria.Predicate` | `getPredicate(ComparableCondition<D> condition, javax.persistence.metamodel.SingularAttribute<? super P,D> attribute, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<P> root)` Generates predicates to satisfy the given filter Comparable filter.
    `<D> javax.persistence.criteria.Predicate` | `getPredicate(EqualityCondition<D> condition, javax.persistence.metamodel.SingularAttribute<? super P,D> attribute, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<P> root)` Generates a predicate to satisfy the given filter Equality Filter.
    `<D extends Comparable<D>> javax.persistence.criteria.Predicate` | `getPredicate(IntervalCondition<D> condition, javax.persistence.metamodel.SingularAttribute<? super P,D> attribute, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<P> root)` Generates predicates to satisfy the given filter Interval filter.
    `<D> javax.persistence.criteria.Predicate` | `getPredicate(SetCondition<D> condition, javax.persistence.metamodel.SingularAttribute<? super P,D> attribute, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<P> root)` Generates predicates to satisfy the given Set filter.
    `javax.persistence.criteria.Predicate` | `getPredicate(StringCondition condition, javax.persistence.metamodel.SingularAttribute<? super P,String> attribute, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<P> root)` Generates predicates to satisfy the given String filter.
    `javax.persistence.criteria.Predicate` | `or(javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Predicate... predicates)` Performs Or operation on the given predicates.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryPredicateGenerator

          public QueryPredicateGenerator()

  - ### Method Detail

    - #### getPredicate

          public <D> javax.persistence.criteria.Predicate getPredicate(EqualityCondition<D> condition,
                                                              javax.persistence.metamodel.SingularAttribute<? super P,D> attribute,
                                                              javax.persistence.criteria.CriteriaBuilder builder,
                                                              javax.persistence.criteria.Root<P> root)

      Generates a predicate to satisfy the given filter Equality Filter. It will produce the Predicate clause which will either exactly match the given input value, or will match anything that is not exactly the same as the given input value.
      Parameters:
        `condition` - condition to apply.
        `attribute` - JPA entity attribute (table column).
        `builder` - CriteriaBuider object for creating the predicate
        `root` - The root element type of the table
      Returns:
        predicate to use in a query.

    - #### getPredicate

          public <D extends Comparable<D>> javax.persistence.criteria.Predicate getPredicate(ComparableCondition<D> condition,
                                                                                    javax.persistence.metamodel.SingularAttribute<? super P,D> attribute,
                                                                                    javax.persistence.criteria.CriteriaBuilder builder,
                                                                                    javax.persistence.criteria.Root<P> root)

      Generates predicates to satisfy the given filter Comparable filter. It will produce the Predicate clause which will allow for comparisons between the objects in the database and the supplied Comparable object. The supplied Comparable object will be responsible for correctly making the comparison decisions.
      Parameters:
        `condition` - condition to apply.
        `attribute` - JPA entity attribute (table column).
        `builder` - CriteriaBuider object for creating the predicate
        `root` - The root element type of the table
      Returns:
        predicate to use in a query.

    - #### getPredicate

          public <D extends Comparable<D>> javax.persistence.criteria.Predicate getPredicate(IntervalCondition<D> condition,
                                                                                    javax.persistence.metamodel.SingularAttribute<? super P,D> attribute,
                                                                                    javax.persistence.criteria.CriteriaBuilder builder,
                                                                                    javax.persistence.criteria.Root<P> root)

      Generates predicates to satisfy the given filter Interval filter. Based on the Interval Type, it will created the necessary Predicates required to match both the left end and the right end boundaries. Depending on the mode of the filter, it will ensure that the Predicate will match items that are constrained within the interval, or external to the interval.
      Parameters:
        `condition` - condition to apply.
        `attribute` - JPA entity attribute (table column).
        `builder` - CriteriaBuider object for creating the predicate
        `root` - The root element type of the table
      Returns:
        predicates to use in a query.

    - #### getPredicate

          public <D> javax.persistence.criteria.Predicate getPredicate(SetCondition<D> condition,
                                                              javax.persistence.metamodel.SingularAttribute<? super P,D> attribute,
                                                              javax.persistence.criteria.CriteriaBuilder builder,
                                                              javax.persistence.criteria.Root<P> root)

      Generates predicates to satisfy the given Set filter. It will produce the Predicate that is required to query against the items that are within the provided set. Based on the mode of the query, it will ensure that the predicate will exactly match against any entry within the provided set, or will return only objects which are not within the provided set.
      Parameters:
        `condition` - condition to apply.
        `attribute` - JPA entity attribute (table column).
        `builder` - CriteriaBuider object for creating the predicate
        `root` - The root element type of the table
      Returns:
        predicates to use in a query.

    - #### getPredicate

          public javax.persistence.criteria.Predicate getPredicate(StringCondition condition,
                                                          javax.persistence.metamodel.SingularAttribute<? super P,String> attribute,
                                                          javax.persistence.criteria.CriteriaBuilder builder,
                                                          javax.persistence.criteria.Root<P> root)

      Generates predicates to satisfy the given String filter. It will build the Predicate object for matching strings based on the desired mode of the filter.
      Parameters:
        `condition` - condition to apply.
        `attribute` - JPA entity attribute (table column).
        `builder` - CriteriaBuider object for creating the predicate
        `root` - The root element type of the table
      Returns:
        predicates to use in a query.

    - #### and

          public javax.persistence.criteria.Predicate and(javax.persistence.criteria.CriteriaBuilder builder,
                                                 javax.persistence.criteria.Predicate... predicates)

      Performs And operation on the given predicates.
      Parameters:
        `builder` - criteria builder.
        `predicates` - predicates to apply And operation to.
      Returns:
        the And operation.

    - #### or

          public javax.persistence.criteria.Predicate or(javax.persistence.criteria.CriteriaBuilder builder,
                                                javax.persistence.criteria.Predicate... predicates)

      Performs Or operation on the given predicates.
      Parameters:
        `builder` - criteria builder.
        `predicates` - predicates to apply And operation to.
      Returns:
        the And operation.

Copyright © 2014. All Rights Reserved.