Skip to content

Package: CriteriaBuilder

CriteriaBuilder

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.query.criteria;
19:
20: /**
21: * Used to construct criteria queries, compound selections, expressions, predicates, orderings.
22: */
23: public interface CriteriaBuilder extends PredicateFactory {
24:
25: /**
26: * Create a CriteriaQuery object with the specified result type.
27: *
28: * @param resultClass type of the query result
29: * @return criteria query object
30: */
31: <T> CriteriaQuery<T> createQuery(Class<T> resultClass);
32:
33: /**
34: * Create an expression that returns the absolute value of its argument.
35: *
36: * @param x expression
37: * @return absolute value
38: */
39: <N extends Number> Expression<N> abs(Expression<N> x);
40:
41: /**
42: * Create an expression that returns the smallest (closest to negative infinity) numeric value that is greater than
43: * or equal to the argument and is equal to a mathematical integer.
44: *
45: * @param x expression
46: * @return ceiling value
47: */
48: <N extends Number> Expression<N> ceil(Expression<N> x);
49:
50: /**
51: * Create an expression that returns the largest (closest to positive infinity) numeric value that is less than or
52: * equal to the argument and is equal to a mathematical integer.
53: *
54: * @param x expression
55: * @return floor value
56: */
57: <N extends Number> Expression<N> floor(Expression<N> x);
58:
59: /**
60: * Create an aggregate expression applying the count operation. Return type of count function in SPARQL is
61: * xsd:integer which JOPA internally represents as Integer.
62: *
63: * @param x expression representing input value to count operation
64: * @return count expression
65: */
66: Expression<Integer> count(Expression<?> x);
67:
68: /**
69: * Create expression to return length of a string.
70: *
71: * @param x string expression
72: * @return length expression
73: */
74: Expression<Integer> length(Expression<String> x);
75:
76: /**
77: * Create a parameter expression.
78: *
79: * @param paramClass parameter class
80: * @return parameter expression
81: */
82: <T> ParameterExpression<T> parameter(Class<T> paramClass);
83:
84: /**
85: * Create a parameter expression with the given name.
86: *
87: * @param paramClass parameter class
88: * @param name name that can be used to refer to the parameter
89: * @return parameter expression
90: */
91: <T> ParameterExpression<T> parameter(Class<T> paramClass, String name);
92:
93: /**
94: * Create an expression for a literal.
95: *
96: * @param value value represented by the expression
97: * @return expression literal
98: */
99: <T> Expression<T> literal(T value);
100:
101: /**
102: * Create an expression for a string literal with language tag.
103: *
104: * @param value string value represented by the expression
105: * @param languageTag string language tag
106: * @return expression literal
107: */
108: Expression<String> literal(String value, String languageTag);
109:
110: /**
111: * Create expression for converting a string to lowercase.
112: *
113: * @param x string expression
114: * @return expression to convert to lowercase
115: */
116: Expression<String> lower(Expression<String> x);
117:
118: /**
119: * Create expression for converting a string to uppercase.
120: *
121: * @param x string expression
122: * @return expression to convert to uppercase
123: */
124: Expression<String> upper(Expression<String> x);
125:
126: /**
127: * Create expression for extracting language tag from a string literal.
128: *
129: * @param x String-valued attribute
130: * @return Expression to extract language tag
131: */
132: Expression<String> lang(Path<String> x);
133:
134: /**
135: * Create an ordering by the ascending value of the expression.
136: *
137: * @param x expression used to define the ordering
138: * @return ascending ordering corresponding to the expression
139: */
140: Order asc(Expression<?> x);
141:
142: /**
143: * Create an ordering by the descending value of the expression.
144: *
145: * @param x expression used to define the ordering
146: * @return descending ordering corresponding to the expression
147: */
148: Order desc(Expression<?> x);
149: }