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 javax.persistence.TupleElement;
20 import java.util.List;
21
22 /**
23 * The <code>Selection</code> interface defines an item that is to be
24 * returned in a query result.
25 *
26 * @param <X> the type of the selection item
27 *
28 * @since 2.0
29 */
30 public interface Selection<X> extends TupleElement<X> {
31
32 /**
33 * Assigns an alias to the selection item.
34 * Once assigned, an alias cannot be changed or reassigned.
35 * Returns the same selection item.
36 * @param name alias
37 * @return selection item
38 */
39 Selection<X> alias(String name);
40
41 /**
42 * Whether the selection item is a compound selection.
43 * @return boolean indicating whether the selection is a compound
44 * selection
45 */
46 boolean isCompoundSelection();
47
48 /**
49 * Return the selection items composing a compound selection.
50 * Modifications to the list do not affect the query.
51 * @return list of selection items
52 * @throws IllegalStateException if selection is not a
53 * compound selection
54 */
55 List<Selection<?>> getCompoundSelectionItems();
56 }
57