Skip to content

Package: TypedQuery

TypedQuery

nameinstructionbranchcomplexitylinemethod
getResultStream()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (C) 2022 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.model.query;
16:
17: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
18:
19: import java.util.List;
20: import java.util.stream.Stream;
21:
22: /**
23: * Interface used to control the execution of typed queries.
24: *
25: * @param <X> Query result type
26: */
27: public interface TypedQuery<X> extends Query {
28:
29: /**
30: * {@inheritDoc}
31: */
32: @Override
33: List<X> getResultList();
34:
35: /**
36: * {@inheritDoc}
37: */
38: @Override
39: default Stream<X> getResultStream() {
40: return getResultList().stream();
41: }
42:
43: /**
44: * {@inheritDoc}
45: */
46: @Override
47: X getSingleResult();
48:
49: /**
50: * {@inheritDoc}
51: */
52: @Override
53: TypedQuery<X> setMaxResults(int maxResult);
54:
55: /**
56: * {@inheritDoc}
57: */
58: @Override
59: TypedQuery<X> setFirstResult(int startPosition);
60:
61: /**
62: * {@inheritDoc}
63: */
64: @Override
65: TypedQuery<X> setParameter(int position, Object value);
66:
67: /**
68: * {@inheritDoc}
69: */
70: @Override
71: TypedQuery<X> setParameter(int position, String value, String language);
72:
73: /**
74: * {@inheritDoc}
75: */
76: @Override
77: TypedQuery<X> setParameter(String name, Object value);
78:
79: /**
80: * {@inheritDoc}
81: */
82: @Override
83: TypedQuery<X> setParameter(String name, String value, String language);
84:
85: /**
86: * {@inheritDoc}
87: */
88: @Override
89: <T> TypedQuery<X> setParameter(Parameter<T> parameter, T value);
90:
91: /**
92: * {@inheritDoc}
93: */
94: @Override
95: TypedQuery<X> setParameter(Parameter<String> parameter, String value, String language);
96:
97: /**
98: * {@inheritDoc}
99: */
100: @Override
101: TypedQuery<X> setUntypedParameter(int position, Object value);
102:
103: /**
104: * {@inheritDoc}
105: */
106: @Override
107: TypedQuery<X> setUntypedParameter(String name, Object value);
108:
109: /**
110: * {@inheritDoc}
111: */
112: @Override
113: <T> TypedQuery<X> setUntypedParameter(Parameter<T> parameter, T value);
114:
115: /**
116: * Sets descriptor to use with this query.
117: * <p>
118: * The descriptor may specify contexts and languages for the retrieved query results. Note that the descriptor
119: * applies only to results of managed types, i.e. when the result type of the query is a managed type. Otherwise,
120: * the descriptor is ignored.
121: * <p>
122: * Use of descriptor may lead to additional result filtering, e.g. when the individual, which is a result of the
123: * query, does not match criteria in the descriptor (it is in a different context, for instance), it is not returned
124: * by {@link #getResultList()} and {@link #getSingleResult()}.
125: *
126: * @param descriptor The descriptor to use
127: * @return This query instance
128: */
129: TypedQuery<X> setDescriptor(Descriptor descriptor);
130: }