Interface ModelCriteriaBuilder<M,​Self extends ModelCriteriaBuilder<M,​Self>>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  ModelCriteriaBuilder.Operator
      The operators are very basic ones for this use case.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Self and​(Self... builders)
      Creates and returns a new instance of ModelCriteriaBuilder that combines the given builders with the Boolean AND operator.
      Self compare​(SearchableModelField<? super M> modelField, ModelCriteriaBuilder.Operator op, Object... value)
      Adds a constraint for the given model field to this criteria builder and returns a criteria builder that is combined with the the new constraint.
      Self not​(Self builder)
      Creates and returns a new instance of ModelCriteriaBuilder that negates the given builder.
      Self or​(Self... builders)
      Creates and returns a new instance of ModelCriteriaBuilder that combines the given builders with the Boolean OR operator.
    • Method Detail

      • compare

        Self compare​(SearchableModelField<? super M> modelField,
                     ModelCriteriaBuilder.Operator op,
                     Object... value)
        Adds a constraint for the given model field to this criteria builder and returns a criteria builder that is combined with the the new constraint. The resulting constraint is a logical conjunction (i.e. AND) of the original constraint present in this ModelCriteriaBuilder and the given operator.
        Parameters:
        modelField - Field on the logical model to be constrained
        op - Operator
        value - Additional operands of the operator.
        Returns:
        Throws:
        CriterionNotSupportedException - If the operator is not supported for the given field.
      • and

        Self and​(Self... builders)
        Creates and returns a new instance of ModelCriteriaBuilder that combines the given builders with the Boolean AND operator.

        Predicate coming out of and on an empty array of builders (i.e. empty conjunction) is always true.

           cb = storage.getCriteriaBuilder();
           storage.read(cb.or(
             cb.and(cb.compare(FIELD1, EQ, 1), cb.compare(FIELD2, EQ, 2)),
             cb.and(cb.compare(FIELD1, EQ, 3), cb.compare(FIELD2, EQ, 4))
           );
         
        Throws:
        CriterionNotSupportedException - If the operator is not supported for the given field.
      • or

        Self or​(Self... builders)
        Creates and returns a new instance of ModelCriteriaBuilder that combines the given builders with the Boolean OR operator.

        Predicate coming out of or on an empty array of builders (i.e. empty disjunction) is always false.

           cb = storage.getCriteriaBuilder();
           storage.read(cb.or(
             cb.compare(FIELD1, EQ, 1).compare(FIELD2, EQ, 2),
             cb.compare(FIELD1, EQ, 3).compare(FIELD2, EQ, 4)
           );
         
        Throws:
        CriterionNotSupportedException - If the operator is not supported for the given field.
      • not

        Self not​(Self builder)
        Creates and returns a new instance of ModelCriteriaBuilder that negates the given builder.

        Note that if the builder has no condition yet, there is nothing to negate: empty negation is always true.

        Parameters:
        builder -
        Returns:
        Throws:
        CriterionNotSupportedException - If the operator is not supported for the given field.