Skip to content

Package: QueryParameter

QueryParameter

nameinstructionbranchcomplexitylinemethod
QueryParameter(Integer, ParameterValueFactory)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
QueryParameter(String, ParameterValueFactory)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
equals(Object)
M: 5 C: 28
85%
M: 5 C: 5
50%
M: 5 C: 1
17%
M: 2 C: 4
67%
M: 0 C: 1
100%
getIdentifier()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getName()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getParameterType()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPosition()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getValue()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 24
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
resetValue()
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setUntypedValue(Object)
M: 4 C: 10
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
setValue(Object)
M: 4 C: 10
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
setValue(String, String)
M: 4 C: 11
73%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
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: * <p>
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.query;
16:
17: import cz.cvut.kbss.jopa.model.query.Parameter;
18: import cz.cvut.kbss.jopa.query.parameter.ParameterValue;
19: import cz.cvut.kbss.jopa.query.parameter.ParameterValueFactory;
20:
21: import java.util.Objects;
22:
23: public class QueryParameter<T> implements Parameter<T> {
24:
25: private final String name;
26: private final Integer position;
27:
28: private final ParameterValueFactory valueFactory;
29:
30: private ParameterValue value;
31:
32: public QueryParameter(String name, ParameterValueFactory valueFactory) {
33: this.name = name;
34: this.valueFactory = valueFactory;
35: this.position = null;
36: resetValue();
37: }
38:
39: public QueryParameter(Integer position, ParameterValueFactory valueFactory) {
40: this.position = position;
41: this.valueFactory = valueFactory;
42: this.name = null;
43: resetValue();
44: }
45:
46: @Override
47: public String getName() {
48: return name;
49: }
50:
51: @Override
52: public Integer getPosition() {
53: return position;
54: }
55:
56: public Object getIdentifier() {
57:• return name != null ? name : position;
58: }
59:
60: public ParameterValue getValue() {
61: return value;
62: }
63:
64: public void setValue(Object value) {
65:• assert value != null;
66: this.value = valueFactory.create(value);
67: }
68:
69: public void setValue(String value, String language) {
70:• assert value != null;
71: this.value = valueFactory.create(value, language);
72: }
73:
74: public void setUntypedValue(Object value) {
75:• assert value != null;
76: this.value = valueFactory.createUntyped(value);
77: }
78:
79: public void resetValue() {
80:• this.value =
81: name != null ? valueFactory.createVariableValue(name) : valueFactory.createVariableValue(position);
82: }
83:
84: @Override
85: public Class<T> getParameterType() {
86: throw new IllegalStateException("Parameter types are not supported by the current implementation.");
87: }
88:
89: @Override
90: public boolean equals(Object o) {
91:• if (this == o) {
92: return true;
93: }
94:• if (o == null || getClass() != o.getClass()) {
95: return false;
96: }
97:
98: QueryParameter<?> that = (QueryParameter<?>) o;
99:• return Objects.equals(name, that.name) && Objects.equals(position, that.position);
100:
101: }
102:
103: @Override
104: public int hashCode() {
105:• int result = name != null ? name.hashCode() : 0;
106:• result = 31 * result + (position != null ? position.hashCode() : 0);
107: return result;
108: }
109: }