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) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.model.query;
14:
15: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
16:
17: import java.util.List;
18: import java.util.stream.Stream;
19:
20: /**
21: * Interface used to control the execution of typed queries.
22: *
23: * @param <X> Query result type
24: */
25: public interface TypedQuery<X> extends Query {
26:
27: /**
28: * {@inheritDoc}
29: */
30: @Override
31: List<X> getResultList();
32:
33: /**
34: * {@inheritDoc}
35: */
36: @Override
37: default Stream<X> getResultStream() {
38: return getResultList().stream();
39: }
40:
41: /**
42: * {@inheritDoc}
43: */
44: @Override
45: X getSingleResult();
46:
47: /**
48: * {@inheritDoc}
49: */
50: @Override
51: TypedQuery<X> setMaxResults(int maxResult);
52:
53: /**
54: * {@inheritDoc}
55: */
56: @Override
57: TypedQuery<X> setFirstResult(int startPosition);
58:
59: /**
60: * {@inheritDoc}
61: */
62: @Override
63: TypedQuery<X> setParameter(int position, Object value);
64:
65: /**
66: * {@inheritDoc}
67: */
68: @Override
69: TypedQuery<X> setParameter(int position, String value, String language);
70:
71: /**
72: * {@inheritDoc}
73: */
74: @Override
75: TypedQuery<X> setParameter(String name, Object value);
76:
77: /**
78: * {@inheritDoc}
79: */
80: @Override
81: TypedQuery<X> setParameter(String name, String value, String language);
82:
83: /**
84: * {@inheritDoc}
85: */
86: @Override
87: <T> TypedQuery<X> setParameter(Parameter<T> parameter, T value);
88:
89: /**
90: * {@inheritDoc}
91: */
92: @Override
93: TypedQuery<X> setParameter(Parameter<String> parameter, String value, String language);
94:
95: /**
96: * {@inheritDoc}
97: */
98: @Override
99: TypedQuery<X> setUntypedParameter(int position, Object value);
100:
101: /**
102: * {@inheritDoc}
103: */
104: @Override
105: TypedQuery<X> setUntypedParameter(String name, Object value);
106:
107: /**
108: * {@inheritDoc}
109: */
110: @Override
111: <T> TypedQuery<X> setUntypedParameter(Parameter<T> parameter, T value);
112:
113: /**
114: * Sets descriptor to use with this query.
115: * <p>
116: * The descriptor may specify contexts and languages for the retrieved query results. Note that the descriptor
117: * applies only to results of managed types, i.e. when the result type of the query is a managed type. Otherwise,
118: * the descriptor is ignored.
119: * <p>
120: * Use of descriptor may lead to additional result filtering, e.g. when the individual, which is a result of the
121: * query, does not match criteria in the descriptor (it is in a different context, for instance), it is not returned
122: * by {@link #getResultList()} and {@link #getSingleResult()}.
123: *
124: * @param descriptor The descriptor to use
125: * @return This query instance
126: */
127: TypedQuery<X> setDescriptor(Descriptor descriptor);
128: }