1 /*
2  * Copyright (c) 2008, 2019 Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v. 2.0 which is available at
6  * http://www.eclipse.org/legal/epl-2.0,
7  * or the Eclipse Distribution License v. 1.0 which is available at
8  * http://www.eclipse.org/org/documents/edl-v10.php.
9  *
10  * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11  */

12
13 // Contributors:
14 //     Linda DeMichiel - 2.1
15 //     Linda DeMichiel - 2.0
16
17 package javax.persistence.criteria;
18
19 import java.util.List;
20
21 /**
22  * The type of a simple or compound predicate: a conjunction or
23  * disjunction of restrictions.
24  * A simple predicate is considered to be a conjunction with a
25  * single conjunct.
26  *
27  * @since 2.0
28  */

29 public interface Predicate extends Expression<Boolean> {
30
31         public static enum BooleanOperator {
32               AND, OR
33         }
34     
35     /**
36      * Return the boolean operator for the predicate.
37      * If the predicate is simple, this is <code>AND</code>.
38      * @return boolean operator for the predicate
39      */

40     BooleanOperator getOperator();
41     
42     /**
43      * Whether the predicate has been created from another
44      * predicate by applying the <code>Predicate.not()</code> method
45      * or the <code>CriteriaBuilder.not()</code> method.
46      * @return boolean indicating if the predicate is 
47      *                 a negated predicate
48      */

49     boolean isNegated();
50
51     /**
52      * Return the top-level conjuncts or disjuncts of the predicate.
53      * Returns empty list if there are no top-level conjuncts or
54      * disjuncts of the predicate.
55      * Modifications to the list do not affect the query.
56      * @return list of boolean expressions forming the predicate
57      */

58     List<Expression<Boolean>> getExpressions();
59
60     /**
61      * Create a negation of the predicate.
62      * @return negated predicate 
63      */

64     Predicate not();
65
66 }
67