Skip to contentPackage: Predicate
Predicate
Coverage
1: /**
2: * Copyright (C) 2023 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: public interface Predicate extends Expression<Boolean> {
20:
21: /**
22: * Return the top-level conjuncts or disjuncts of the predicate. Returns empty list if there are no top-level
23: * conjuncts or disjuncts of the predicate.
24: *
25: * @return list of boolean expressions forming the predicate
26: */
27: List<Expression<Boolean>> getExpressions();
28:
29: /**
30: * Return the boolean operator for the predicate. If the predicate is simple, this is AND.
31: *
32: * @return boolean operator for the predicate
33: */
34: Predicate.BooleanOperator getOperator();
35:
36: /**
37: * Create a negation of the predicate.
38: *
39: * @return negated predicate
40: */
41: Predicate not();
42:
43: /**
44: * Determines if the predicate has been created from another predicate by applying the Predicate.not() method.
45: *
46: * @return boolean indicating if the predicate is a negated predicate
47: */
48: boolean isNegated();
49:
50: enum BooleanOperator {
51: AND("AND"),
52: OR("OR");
53:
54: private final String operator;
55:
56: BooleanOperator(String operator) {
57: this.operator = operator;
58: }
59:
60: @Override
61: public String toString() {
62: return operator;
63: }
64: }
65: }