Skip to content

Package: AbstractStorableQuery

AbstractStorableQuery

nameinstructionbranchcomplexitylinemethod
AbstractStorableQuery()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
AbstractStorableQuery(KapuaId)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
addFetchAttributes(String)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getFetchAttributes()
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getFetchStyle()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getLimit()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getOffset()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPredicate()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getScopeId()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSortFields()
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
isAskTotalCount()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setAskTotalCount(boolean)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setFetchAttributes(List)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setFetchStyle(StorableFetchStyle)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setLimit(Integer)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setOffset(Integer)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setPredicate(StorablePredicate)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setScopeId(KapuaId)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setSortFields(List)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: * Red Hat Inc
13: *******************************************************************************/
14: package org.eclipse.kapua.service.storable.model.query;
15:
16: import org.eclipse.kapua.commons.model.id.KapuaEid;
17: import org.eclipse.kapua.model.id.KapuaId;
18: import org.eclipse.kapua.service.storable.model.query.predicate.StorablePredicate;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: /**
24: * {@link StorableQuery} {@code abstract} implementation.
25: * <p>
26: * Is the base for all {@link StorableQuery} implementations.
27: *
28: * @since 1.0.0
29: */
30: public abstract class AbstractStorableQuery implements StorableQuery {
31:
32: private StorablePredicate predicate;
33:
34: private KapuaId scopeId;
35: private Integer limit;
36: private Integer indexOffset;
37: private boolean askTotalCount;
38: private List<SortField> sortFields;
39: private StorableFetchStyle fetchStyle;
40: private List<String> fetchAttributes;
41:
42: /**
43: * Constructor.
44: * <p>
45: * Forces the {@link StorableFetchStyle} to {@link StorableFetchStyle#SOURCE_FULL}
46: *
47: * @since 1.0.0
48: */
49: public AbstractStorableQuery() {
50: super();
51:
52: setFetchStyle(StorableFetchStyle.SOURCE_FULL);
53: }
54:
55: /**
56: * Constructor.
57: *
58: * @param scopeId The scope KapuaId.
59: * @since 1.0.0
60: */
61: public AbstractStorableQuery(KapuaId scopeId) {
62: this();
63:
64: setScopeId(scopeId);
65: }
66:
67: /**
68: * Gets the {@link StorableField}s.
69: *
70: * @return The {@link StorableField}s.
71: * @since 1.0.0
72: */
73: public abstract String[] getFields();
74:
75: @Override
76: public KapuaId getScopeId() {
77: return scopeId;
78: }
79:
80: @Override
81: public void setScopeId(KapuaId scopeId) {
82: this.scopeId = KapuaEid.parseKapuaId(scopeId);
83: }
84:
85: @Override
86: public StorablePredicate getPredicate() {
87: return this.predicate;
88: }
89:
90: @Override
91: public void setPredicate(StorablePredicate predicate) {
92: this.predicate = predicate;
93: }
94:
95: @Override
96: public Integer getOffset() {
97: return indexOffset;
98: }
99:
100: @Override
101: public void setOffset(Integer offset) {
102: this.indexOffset = offset;
103: }
104:
105: @Override
106: public void setLimit(Integer limit) {
107: this.limit = limit;
108: }
109:
110: @Override
111: public Integer getLimit() {
112: return limit;
113: }
114:
115: @Override
116: public boolean isAskTotalCount() {
117: return askTotalCount;
118: }
119:
120: @Override
121: public void setAskTotalCount(boolean askTotalCount) {
122: this.askTotalCount = askTotalCount;
123: }
124:
125: @Override
126: public List<SortField> getSortFields() {
127:• if (sortFields == null) {
128: sortFields = new ArrayList<>();
129: }
130:
131: return sortFields;
132: }
133:
134: @Override
135: public void setSortFields(List<SortField> sortFields) {
136: this.sortFields = sortFields;
137: }
138:
139: @Override
140: public StorableFetchStyle getFetchStyle() {
141: return this.fetchStyle;
142: }
143:
144: @Override
145: public void setFetchStyle(StorableFetchStyle fetchStyle) {
146: this.fetchStyle = fetchStyle;
147: }
148:
149: @Override
150: public List<String> getFetchAttributes() {
151:• if (fetchAttributes == null) {
152: fetchAttributes = new ArrayList<>();
153: }
154:
155: return fetchAttributes;
156: }
157:
158: @Override
159: public void addFetchAttributes(String fetchAttribute) {
160: getFetchAttributes().add(fetchAttribute);
161: }
162:
163: @Override
164: public void setFetchAttributes(List<String> fetchAttributeNames) {
165: fetchAttributes = fetchAttributeNames;
166: }
167: }