Skip to contentPackage: CriteriaBuilder
CriteriaBuilder
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.sessions;
16:
17: import cz.cvut.kbss.jopa.model.query.criteria.CriteriaQuery;
18: import cz.cvut.kbss.jopa.model.query.criteria.Expression;
19: import cz.cvut.kbss.jopa.model.query.criteria.Order;
20: import cz.cvut.kbss.jopa.model.query.criteria.ParameterExpression;
21:
22: /**
23: * Used to construct criteria queries, compound selections, expressions, predicates, orderings.
24: */
25: public interface CriteriaBuilder extends PredicateFactory {
26:
27: /**
28: * Create a CriteriaQuery object with the specified result type.
29: *
30: * @param resultClass type of the query result
31: * @return criteria query object
32: */
33: <T> CriteriaQuery<T> createQuery(Class<T> resultClass);
34:
35: /**
36: * Create an expression that returns the absolute value of its argument.
37: *
38: * @param x expression
39: * @return absolute value
40: */
41: <N extends Number> Expression<N> abs(Expression<N> x);
42:
43: /**
44: * Create an expression that returns the smallest (closest to negative infinity) numeric value that is greater than
45: * or equal to the argument and is equal to a mathematical integer.
46: *
47: * @param x expression
48: * @return ceiling value
49: */
50: <N extends Number> Expression<N> ceil(Expression<N> x);
51:
52: /**
53: * Create an expression that returns the largest (closest to positive infinity) numeric value that is less than or
54: * equal to the argument and is equal to a mathematical integer.
55: *
56: * @param x expression
57: * @return floor value
58: */
59: <N extends Number> Expression<N> floor(Expression<N> x);
60:
61: /**
62: * Create an aggregate expression applying the count operation. Return type of count function in SPARQL is
63: * xsd:integer which JOPA internally represents as Integer.
64: *
65: * @param x expression representing input value to count operation
66: * @return count expression
67: */
68: Expression<Integer> count(Expression<?> x);
69:
70: /**
71: * Create expression to return length of a string.
72: *
73: * @param x string expression
74: * @return length expression
75: */
76: Expression<Integer> length(Expression<String> x);
77:
78: /**
79: * Create a parameter expression.
80: *
81: * @param paramClass parameter class
82: * @return parameter expression
83: */
84: <T> ParameterExpression<T> parameter(Class<T> paramClass);
85:
86: /**
87: * Create a parameter expression with the given name.
88: *
89: * @param paramClass parameter class
90: * @param name name that can be used to refer to the parameter
91: * @return parameter expression
92: */
93: <T> ParameterExpression<T> parameter(Class<T> paramClass, String name);
94:
95: /**
96: * Create an expression for a literal.
97: *
98: * @param value value represented by the expression
99: * @return expression literal
100: */
101: <T> Expression<T> literal(T value);
102:
103: /**
104: * Create an expression for a string literal with language tag.
105: *
106: * @param value string value represented by the expression
107: * @param languageTag string language tag
108: * @return expression literal
109: */
110: Expression<String> literal(String value, String languageTag);
111:
112: /**
113: * Create expression for converting a string to lowercase.
114: *
115: * @param x string expression
116: * @return expression to convert to lowercase
117: */
118: Expression<String> lower(Expression<String> x);
119:
120: /**
121: * Create expression for converting a string to uppercase.
122: *
123: * @param x string expression
124: * @return expression to convert to uppercase
125: */
126: Expression<String> upper(Expression<String> x);
127:
128: /**
129: * Create an ordering by the ascending value of the expression.
130: *
131: * @param x expression used to define the ordering
132: * @return ascending ordering corresponding to the expression
133: */
134: Order asc(Expression<?> x);
135:
136: /**
137: * Create an ordering by the descending value of the expression.
138: *
139: * @param x expression used to define the ordering
140: * @return descending ordering corresponding to the expression
141: */
142: Order desc(Expression<?> x);
143: }