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.Collection;
20
21 /**
22  * Type for query expressions.
23  *
24  * @param <T> the type of the expression
25  *
26  * @since 2.0
27  */

28 public interface Expression<T> extends Selection<T> {
29
30     /**
31      *  Create a predicate to test whether the expression is null.
32      *  @return predicate testing whether the expression is null
33      */

34     Predicate isNull();
35
36     /**
37      *  Create a predicate to test whether the expression is 
38      *  not null.
39      *  @return predicate testing whether the expression is not null
40      */

41     Predicate isNotNull();
42
43     /**
44      * Create a predicate to test whether the expression is a member
45      * of the argument list.
46      * @param values  values to be tested against
47      * @return predicate testing for membership
48      */

49     Predicate in(Object... values);
50
51     /**
52      * Create a predicate to test whether the expression is a member
53      * of the argument list.
54      * @param values  expressions to be tested against
55      * @return predicate testing for membership
56      */

57     Predicate in(Expression<?>... values);
58
59     /**
60      * Create a predicate to test whether the expression is a member
61      * of the collection.
62      * @param values  collection of values to be tested against
63      * @return predicate testing for membership
64      */

65     Predicate in(Collection<?> values);
66
67     /**
68      * Create a predicate to test whether the expression is a member
69      * of the collection.
70      * @param values expression corresponding to collection to be
71      *        tested against
72      * @return predicate testing for membership
73      */

74     Predicate in(Expression<Collection<?>> values);
75
76     /**
77      * Perform a typecast upon the expression, returning a new
78      * expression object.
79      * This method does not cause type conversion:
80      * the runtime type is not changed.
81      * Warning: may result in a runtime failure.
82      * @param type  intended type of the expression
83      * @return new expression of the given type
84      */

85     <X> Expression<X> as(Class<X> type);
86 }
87