Skip to content

Package: PathImpl

PathImpl

nameinstructionbranchcomplexitylinemethod
PathImpl(Metamodel, AbstractPathExpression, FieldSpecification, CriteriaBuilder)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
resolveBindableJavaType(FieldSpecification)
M: 4 C: 15
79%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 4
100%
M: 0 C: 1
100%
setExpressionToQuery(StringBuilder, CriteriaParameterFiller)
M: 5 C: 17
77%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
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) 2023 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.query.criteria;
16:
17: import cz.cvut.kbss.jopa.model.metamodel.Bindable;
18: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
19: import cz.cvut.kbss.jopa.model.metamodel.Metamodel;
20: import cz.cvut.kbss.jopa.model.metamodel.TypesSpecification;
21: import cz.cvut.kbss.jopa.model.query.criteria.Path;
22: import cz.cvut.kbss.jopa.query.criteria.expressions.AbstractPathExpression;
23: import cz.cvut.kbss.jopa.sessions.CriteriaBuilder;
24:
25: public class PathImpl<X> extends AbstractPathExpression<X> implements Path<X> {
26:
27: protected String attributeName;
28: protected FieldSpecification<?, ?> attribute;
29:
30: public PathImpl(Metamodel metamodel, AbstractPathExpression pathSource, FieldSpecification<?, ?> attribute,
31: CriteriaBuilder cb) {
32: super(resolveBindableJavaType(attribute), pathSource, metamodel, cb);
33: this.attribute = attribute;
34: this.attributeName = attribute.getName();
35: }
36:
37: private static <E> Class<E> resolveBindableJavaType(FieldSpecification<?, ?> attribute) {
38:• if (attribute instanceof TypesSpecification) {
39: return ((TypesSpecification) attribute).getElementType();
40: }
41:• assert attribute instanceof Bindable;
42: return ((Bindable<E>) attribute).getBindableJavaType();
43: }
44:
45: @Override
46: public void setExpressionToQuery(StringBuilder query, CriteriaParameterFiller parameterFiller) {
47:• if (this.pathSource != null) {
48: this.pathSource.setExpressionToQuery(query, parameterFiller);
49: query.append('.').append(attributeName);
50: } else {
51: query.append(attributeName);
52: }
53: }
54:
55: }