Skip to content

Package: Predicate

Predicate

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.query.criteria;
16:
17: import java.util.List;
18:
19: /**
20: * The type of a simple or compound predicate: a conjunction or disjunction of
21: * restrictions. A simple predicate is considered to be a conjunction with a
22: * single conjunct.
23: */
24: public interface Predicate extends Expression<Boolean> {
25:         public static enum BooleanOperator {
26:                 AND, OR
27:         }
28:
29:         /**
30:          * Return the boolean operator for the predicate. If the predicate is
31:          * simple, this is AND.
32:          *
33:          * @return boolean operator for the predicate
34:          */
35:         BooleanOperator getOperator();
36:
37:         /**
38:          * Whether the predicate has been created from another predicate by applying
39:          * the Predicate not() method or the CriteriaBuilder not() method.
40:          *
41:          * @return boolean indicating if the predicate is
42:          *
43:          * a negated predicate
44:          */
45:         boolean isNegated();
46:
47:         /**
48:          * Return the top-level conjuncts or disjuncts of the predicate. Returns
49:          * empty list if there are no top-level conjuncts or disjuncts of the
50:          * predicate. Modifications to the list do not affect the query.
51:          *
52:          * @return list of boolean expressions forming the predicate
53:          */
54:         List<Expression<Boolean>> getExpressions();
55:
56:         /**
57:          * Create a negation of the predicate.
58:          *
59:          * @return negated predicate
60:          */
61:         Predicate not();
62: }