1 package org.synchronoss.cpo.core;
2
3 /*-
4 * [[
5 * core
6 * ==
7 * Copyright (C) 2003 - 2026 Exaxis LLC, Synchronoss Technologies Inc
8 * ==
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * ]]
23 */
24
25 import org.synchronoss.cpo.core.meta.domain.CpoClass;
26
27 /**
28 * CpoOrderBy is an interface for specifying the sort order in which objects are returned from the
29 * Datasource.
30 *
31 * @author david berry
32 */
33 public interface CpoOrderBy {
34
35 /** Default marker string searched for and replaced by the generated order-by expression. */
36 String DEFAULT_MARKER = "__CPO_ORDERBY__";
37
38 /**
39 * Gets the boolean that determines if the objects will be returned from from the CpoAdapter in
40 * Ascending order or Descending order
41 *
42 * @return boolean true if it is to sort in Ascensing Order false if it is to be sorted in
43 * Descending Order
44 */
45 boolean getAscending();
46
47 /**
48 * Gets the name of the attribute that is to be used to sort the results from the CpoAdapter.
49 *
50 * @return String The name of the attribute
51 */
52 String getAttribute();
53
54 /**
55 * Gets a string representing a datasource specific function call that must be applied to the
56 * attribute that will be used for sorting.
57 *
58 * <p>i.e. - "upper(attribute_name)"
59 *
60 * @return String The name of the function
61 */
62 String getFunction();
63
64 /**
65 * Gets the string marker that this cpoOrderBy will search for in the expression to replace
66 *
67 * @return String The marker of the CpoOrderBy
68 */
69 String getMarker();
70
71 /**
72 * Builds the native (SQL/CQL) order-by fragment for this clause against the given class's
73 * attribute-to-column mapping.
74 *
75 * @param cpoClass the class metadata used to resolve the attribute to a datastore column
76 * @return the string that will be added into the expression
77 * @throws CpoException if the attribute cannot be resolved against {@code cpoClass}
78 */
79 String toString(CpoClass cpoClass) throws CpoException;
80 }